Hello,
I would like to know if it is possible to remove or completely disable the Heartbeat API requirement from all components excluding Activity, which reduces total requests to server. I am not sure how this will affect the component for notifications and messages.
Thanks
Hi Tosin,
Please use the followingadd_action( 'init', 'stop_heartbeat', 1 ); function stop_heartbeat() { if ( bp_is_activity_component() || bp_is_group_activity() ) { return; } wp_deregister_script( 'heartbeat' ); }
Regards
BrajeshThank you very much brajesh I would also like to ask if your plugin https://wordpress.org/plugins/bp-live-notification/ would still work with the above code if not is there a way to bypass it.
Thanks
Hi Tosin,
yes, It will affect that plugin.I am sorry, but there is no alternative. The live notification needs heartbat to work.
Regards
BrajeshHello brajesh
The sitewide activity directory is not being excluded with your code above and below. I need heartbeat to load only sitewide activity directory
add_action( 'init', 'stop_heartbeat', 1 ); function stop_heartbeat() { if ( bp_is_activity_directory() && bp_is_user_activity() && bp_is_activity_component() && bp_is_group_activity() ) { return; } wp_deregister_script( 'heartbeat' ); }
Thanks
Hi Tosin,
try changing the orderadd_action( 'template_redirect', 'stop_heartbeat', 1 ); function stop_heartbeat() { if ( bp_is_activity_component() || bp_is_group_activity() ) { return; } wp_deregister_script( 'heartbeat' ); }
That should work.
PS:- It makes heartbeat work on activity directory, user’s own activity page and group’s activity page.
Regards
Brajesh
You must be logged in to reply to this topic.