Hello Brajesh,
I would like to skip the forced redirect on non BuddyPress pages with this force follow function you provided, The redirection should only occur on buddypress pages.
Thanks
/** * Buddydev force follow 6 members function. */ function buddydev_check_or_redirect() { if ( ! function_exists( 'bp_follow_get_the_following_count' ) || ! is_user_logged_in() || is_super_admin() ) { return; } $fp_active = class_exists( 'BD_Force_User_Avatar_Helper') ; $is_dir = bp_is_members_directory(); // if we are on directory and force profile is not active // return. if ( $is_dir && ! $fp_active ) { return ; } $follow_count = bp_follow_get_the_following_count( array( 'object_id' => get_current_user_id() ) ); if ( $follow_count >= 6 ) { return; } if ( $is_dir && $fp_active ) { remove_action( 'bp_template_redirect', array( BD_Force_User_Avatar_Helper::get_instance(), 'check_or_redirect' ), 1 ); return; } bp_core_add_message( __( 'Please follow 3 more members to continue.' ), 'error' ); bp_core_redirect( bp_get_members_directory_permalink() ); } add_action( 'bp_template_redirect', 'buddydev_check_or_redirect', 0 );
Hi Tosin,
Do you want to skip for all or logged in users only?Regards
BrajeshHi Tosin,
Here is your update function/** * Buddydev force follow 6 members function. */ function buddydev_check_or_redirect() { // Force profile photo active? $fp_active = class_exists( 'BD_Force_User_Avatar_Helper' ); // skip if logged and on non bp page. if ( is_user_logged_in() && ! is_buddypress() ) { if ( $fp_active ) { remove_action( 'bp_template_redirect', array( BD_Force_User_Avatar_Helper::get_instance(), 'check_or_redirect', ), 1 ); } return; } if ( ! function_exists( 'bp_follow_get_the_following_count' ) || ! is_user_logged_in() || is_super_admin() ) { return; } $is_dir = bp_is_members_directory(); // if we are on directory and force profile is not active // return. if ( $is_dir && ! $fp_active ) { return; } $follow_count = bp_follow_get_the_following_count( array( 'object_id' => get_current_user_id() ) ); if ( $follow_count >= 6 ) { return; } if ( $is_dir && $fp_active ) { remove_action( 'bp_template_redirect', array( BD_Force_User_Avatar_Helper::get_instance(), 'check_or_redirect', ), 1 ); return; } bp_core_add_message( __( 'Please follow 3 more members to continue.' ), 'error' ); bp_core_redirect( bp_get_members_directory_permalink() ); } add_action( 'bp_template_redirect', 'buddydev_check_or_redirect', 0 );
Please give it a try.
Thank you
BrajeshHappy New Year Tosin 🙂
I am glad it worked.
Regards
Brajesh
Viewing 6 posts - 1 through 6 (of 6 total)
The topic ‘ [Resolved] Do not force redirect on non BuddyPress pages with force follow function’ is closed to new replies.
This topic is: resolved