BuddyDev

Search

[Resolved] Friends Only Activity Stream


  • Participant
    Level: Initiated
    Posts: 20
    With BenefitZ on #1342

    Hello Brajesh,

    Do you have any code/plugin to filter user’s activity stream to friends only?

    Thanks


  • Keymaster
    (BuddyDev Team)
    Posts: 12076
    Brajesh Singh on #1343

    Do you mean you want it on sitewide activity? It is very easy to do. Just need confirmation where you want it to be, on sitewide activity page or on user profile page?


  • Participant
    Level: Initiated
    Posts: 20
    With BenefitZ on #1344

    Thanks, I need it on the sitewide activity page.


  • Keymaster
    (BuddyDev Team)
    Posts: 12076
    Brajesh Singh on #1345

    Please put the following code in your bp-custom.php and it should work.

    
    
    function buddydev_friends_only_activity_args( $args ) {
    	
    	if( ! bp_is_activity_directory() || !  is_user_logged_in() ) {
    		return $args;
    	}
    	
    	$user_id = get_current_user_id();
    	
    	$user_ids = friends_get_friend_user_ids( $user_id );
    	
    	//include users own too?
    	array_push( $user_ids, $user_id );
    	
    	$args['user_id'] = $user_ids;
    	
    	//print_r($args);
    	return $args;
    
    }
    add_filter( 'bp_after_has_activities_parse_args', 'buddydev_friends_only_activity_args' );
    
    

    hope that helps.

    • This reply was modified 3 years, 9 months ago by  Brajesh Singh.

  • Participant
    Level: Initiated
    Posts: 20
    With BenefitZ on #1346

    Ooops….other plugins are conflicting with any code i put in the bp-custom.php.

    Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /home/xyz/public_html/plugins/bp-custom.php:21) in /home/xyz/public_html/plugins/dhvc-form/dhvc-form.php on line 68

    Warning: Cannot modify header information – headers already sent by (output started at /home/bkwb/public_html/wp-content/plugins/bp-custom.php:21) in /home/xyz/public_html/wp-content/plugins/hide_my_wp/hide-my-wp.php on line 1431

    I’ll disable the plugins and observe the result.


  • Keymaster
    (BuddyDev Team)
    Posts: 12076
    Brajesh Singh on #1347

    Hi,
    Can you please post your bp-custom.php on pastebin? There seems to be some space before opening/after closing php tag causing it. There is an easy fix to remove the spaces.


  • Participant
    Level: Initiated
    Posts: 20
    With BenefitZ on #1348

    Thanks Brajesh,

    Its working now but the message below shows just above the filtered activity stream.

    Array ( [display_comments] => threaded [include] => [exclude] => [in] => [sort] => DESC [page] => 1 [per_page] => 20 [page_arg] => acpage [max] => [count_total] => [show_hidden] => [spam] => ham_only [scope] => [user_id] => Array ( [0] => 5 ) [object] => [action] => [primary_id] => [secondary_id] => [offset] => [since] => [meta_query] => [date_query] => [filter_query] => [search_terms] => [update_meta_cache] => 1 )

    the pastebin link http://pastebin.com/20UXHQKt


  • Keymaster
    (BuddyDev Team)
    Posts: 12076
    Brajesh Singh on #1350

    Hi,
    I have update the code in my 2nd post. I left a print_r there that was showing the output. Sorry about that.


  • Participant
    Level: Initiated
    Posts: 20
    With BenefitZ on #1351

    Thanks Brajesh, It working now. 👍

    I’m buying one of your premium plugin for this.


  • Keymaster
    (BuddyDev Team)
    Posts: 12076
    Brajesh Singh on #1352

    Thank you Israel.
    I am glad that it is working. Appreciate your generosity 🙂

You must be logged in to reply to this topic.

This topic is: resolved
Subscribe