It’s because the js code is written to work with buddypress pages. Still you can take references from here https://stackoverflow.com/questions/14491524/adding-add-friend-button-anywhere-in-the-buddypress-site
And see if this of any help or not.
Thanks
no, I know how to add the add-friend button but do I need to include the buddypress js somewhere to make it works with ajax? thanks
You can try enqueuing that with the conditional tag like:
function ps_buddypress_js_load(){
if(is_home()){
wp_register_script('buddypress', plugins_url( '/buddypress/bp-templates/bp-legacy/js/buddypress.js' , 'buddypress' ) );
wp_enqueue_script('buddypress');
}
}
add_action('wp_enqueue_scripts', 'ps_buddypress_js_load');
If you are using the nouveau template then can change the path accordingly.
Thanks
Thanks, I’ve tried the code but its not working with both nouveau and legacy
@prashantvatsh
any news about it @prashantvatsh thanks
Hi,
Sorry for the delay. I am not on my system but you can debug the code by echoing something just after is_home(){ to see if it is coming in the condition.
If you don’t know how to code, no worries I will check and reply soon.
@prashantvatsh the condition is ok, the problem is that even if I include buddypress.js or buddypress-nouveau.js its not working
Ok, please let me know which template pack you are using right now?
Hi, sorry to jump on this thread but I’ve written my own and gotten nowhere. I need to bind the “add friend” action onto a jquery event. This means I can’t have the page reload when a new friend request is sent. Is there a way to trigger “add friend” in ajax/jquery without the user clicking on anything or the page reloading? It needs to happen in the background.
Thanks!