BuddyDev

Search

Replies

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14444

    Hello Brajesh,

    The stated code did not work it was this code stated below that worked

     /**
     * Set default activity directory tab for BuddyPress
     */
    function buddydev_set_default_activity_directory_tab() {
        // If user is not logged in or
        // If the scope is already set, do not do anything ok.
        if ( ! is_user_logged_in() || isset( $_COOKIE['bp-activity-scope'] ) ) {
            return ;
        }
        // additional check for activity dir
        if ( ! bp_is_activity_directory() ) {
            return ;
        }
        $tab = 'following'; // 'all', 'friends', 'groups', 'mentions'
        // Set scope to our needed tab,
        // In this case, I am setting to the 'friends' tab
        setcookie( 'bp-activity-scope', $tab,null, '/' );
        $_COOKIE['bp-activity-scope'] = $tab;
    }
    add_action( 'bp_template_redirect', 'buddydev_set_default_activity_directory_tab' ); 

    and I also applied the second code like this

     <?php if( ! is_user_logged_in() ) :?>
    		
    			<?php do_action( 'bp_before_activity_type_tab_all' ); ?>
    
    			<li class="selected" id="activity-all"><a href="<?php bp_activity_directory_permalink(); ?>" title="<?php esc_attr_e( 'The public activity for everyone on this site.', 'klein' ); ?>"><?php printf( __( 'All Members <span>%s</span>', 'klein' ), bp_get_total_member_count() ); ?></a></li>
    
    			<?php endif;?> 
  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Buddypress Force follow 5 members after registration #14434

    Hello Brajesh,

    I think we can count friendship request sent by the logged in user but the count should be limited to 3 friendship request and the error message can be (Connect with 3 new friends to continue)

    Regards
    Tosin

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14417

    Hello Brajesh,

    I got it to work by editing the /buddypress/activity/index.php and removing the (all members) code. I later copied the edited file into my theme and applied the code stated below, now all logged in users are automatically viewing activities of people their following.

     /**
     * Filter sitewide activity to list following user's activity.
     *
     * @param array $args args.
     *
     * @return array
     */
    function buddydev_custom_list_activities_filter( $args ) {
    	if ( ! is_user_logged_in() || ! bp_is_members_directory() ) {
    		return $args;
    	}
    
    	// for logged in user, change scope to following.
    	$args['scope'] = 'follow';
    
    	return $args;
    }
    
    add_filter( 'bp_after_has_activities_parse_args', 'buddydev_custom_list_activities_filter' ); 

    The only bad effect is that it removed (all members) tab for logged out user, so I was forced to block access to site wide activity page for logged out users.

    Thank you

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Buddypress Force follow 5 members after registration #14416

    Hello,

    Mr Brajesh your code worked sucessfully. Thank you very very much i’m really grateful. Infact you just made this Nigerian boy very happy God bless you.

    I was wondering if this code can be replicated for FRIENDSHIP connections if possible, please share this code in your blog for other users to benefit.

    This code will foster better connections on buddypress sites

    You are simply the best, God bless.

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14393

    I also changed my theme to wordpress tweenty fourteen theme and the problem still occurs.

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14389

    I applied the stated code but no changes. Activities are still changing automatically from (following) to (all members) upon clicking on staus update form

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14387

    I also tried this code you provided and I got the same result which is the filter keeps changing back to (all members) when I click on the status update form(what’s new form)

    /**
     * Set default activity directory tab for BuddyPress
     */
    function buddydev_set_default_activity_directory_tab() {
        // If user is not logged in or
        // If the scope is already set, do not do anything ok.
        if ( ! is_user_logged_in() || isset( $_COOKIE['bp-activity-scope'] ) ) {
            return ;
        }
        // additional check for activity dir
        if ( ! bp_is_activity_directory() ) {
            return ;
        }
        $tab = 'following'; // 'all', 'friends', 'groups', 'mentions'
        // Set scope to our needed tab,
        // In this case, I am setting to the 'friends' tab
        setcookie( 'bp-activity-scope', $tab,null, '/' );
        $_COOKIE['bp-activity-scope'] = $tab;
    }
    add_action( 'bp_template_redirect', 'buddydev_set_default_activity_directory_tab' );
  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14385

    Hello

    Thank you for the code, I am using the latest update of buddypress follow from gith hub. I applied your code and it worked successfully but I noticed a problem which was when I logged into the site wide activities page the activities being displayed were that of users im following, but when I wanted to post a status update by clicking on status update form the activity tab filter automatically changed back to (all members) without clicking on the all members tab.

    I would like to disable the (all members) tab totally, if possible to remove it.

  • Participant
    Level: Guru
    Posts: 885

    Ok this will work, all I have to do is create a new custom user role and automatically assign the role with the necessary member types. So when a new user registers as either a brand or business his role will automatically be registered as the custom role. You can paste the code.

    Thank you very much for your help I really appreciate your effort.

  • Participant
    Level: Guru
    Posts: 885

    Ok thanks

    Alternatively, what about removeing the friend tab in the navigation menu and drop down menu for one or more specific member types. This should solve the problem