Changing "Add friend button" (ajax)
-
Hello,
I’m trying to change text and some classes for add to friend button. I managed to do so using bp_get_add_friend_button wp filter. The problem is when you click on the button there is ajax call and changes are not applied until page is refreshed. Is there any filter to change button that is returned by ajax? It is bp_dtheme_ajax_addremove_friend function. Here is my function that works after refresh:
function theme_add_friend_link_text($button) {
$fricon_remove = '<i class="fa fa-times" data-original-title="'.__("Remove friend", "domain").'" data-toggle="tooltip"></i>';
$fricon_add = '<i class="fa fa-user"></i>';
$fricon_cancel = '<i class="fa fa-times" data-original-title="'.__("Cancel request!", "domain").'" data-toggle="tooltip"></i>';switch ( $button['id'] ) {
case 'pending' :
$button['link_text'] = $fricon_cancel.__(' Cancel request!', 'domain');
$button['link_title'] = 'Cancel friend request';
$button['link_class'] .= ' add-friend';
break;case 'is_friend' :
$button['link_text'] = $fricon_remove.__(' Remove friend!', 'domain');;
$button['link_class'] .= ' add-friend';
break;default:
$button['link_text'] = $fricon_add.__(' Add as a friend!', 'domain');
$button['link_title'] = 'Add as a friend';
$button['link_class'] .= ' add-friend';
}
return $button;
}
add_filter('bp_get_add_friend_button', 'theme_add_friend_link_text');
- The topic ‘Changing "Add friend button" (ajax)’ is closed to new replies.