BuddyDev

Search

[Resolved] Hiding activity for just one specific user

  • Participant
    Level: Enlightened
    Posts: 46
    Kristian Yngve on #21293

    Hi Brajesh,

    So I have seen your post: https://buddydev.com/exclude-users-from-members-directory-on-a-buddypress-based-social-network/

    and I have used it for the id user: 297 but it isn’t working.

    I believe I am doing something wrong with the code (the first one in that post):

    So I see this part (I have entered 297 for the user): $excluded_user = '297';// comma separated ids of users whom you want to exclude.

    but there is also this part: add_action( 'bp_ajax_querystring', 'bpdev_exclude_users', 20, 2 );

    Do I replace the 20, 2 with 297?

    Either way, it still isn’t working, and it’s not hiding the user.

    What exactly is the code I can use to hide all activity of user: 297 from everybody?

    Many thanks to you.

    Kristian

  • Participant
    Level: Enlightened
    Posts: 46
    Kristian Yngve on #21294

    Ah I think i got it all wrong! the code was for members directory…

    Sorry, I mean, what would be the code to also hide in activity?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #21300

    Hi Kristian,

    You can use the following

    
    
    /**
     * Exclude a user's activity from listing.
     *
     * @param array $args args.
     *
     * @return array
     */
    function buddydev_exclude_single_user_activities( $args ) {
    
    	$args['filter_query'] = array(
    		array(
    			'column'  => 'user_id',
    			'value'   => 46, // update with your own user id.
    			'compare' => '!=',
    		),
    	);
    
    	return $args;
    }
    
    add_filter( 'bp_after_has_activities_parse_args', 'buddydev_exclude_single_user_activities' );
    
    

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 46
    Kristian Yngve on #21307

    Hi Brajesh,

    and thank you for getting back to me.

    Sadly, this didn’t work. I even made sure it was the only thing in my bp custom file (in theme plugins), and I also removed my functions in case of any interfering, but it just isn’t working.

    Brajesh, may you please see if your code can be looked at again? Happy to try a revised code in order to get it to work.

    Thank you so much, and looking forward to hearing from you again.

    Regards,

    Kristain

  • Participant
    Level: Enlightened
    Posts: 46
    Kristian Yngve on #21315

    More findings – I found the code also created a bug on logging in (despite not working) for some reason. once logged in, if you go to the homescreen – it acts as if you are logged out and asks you to log in. The bug is gone when I removed the above code out of my bp custom file. – just more info I thought you’d need to know to help to a solution. 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #21316

    Hi Kristian,
    I am sorry, It seems you are mixing it with something else.
    The code is only affecting the arguements for activity loop. There is no way it can affect your login unless there is something else wrong. It can not create the login related bug, I can assure you about that.

    About the code not working:- The only reason is may not work is either you are not looking at activity loop via bp_has_activities() or something else is modifying the activities.

    The above code will exclude a users’s activity from sitewide activity page as well as other places where bp_has_activities() has been used.

    There is a possibility that a plugin like BuddyPress wall, Facebook Like Activity Stream, activity privacy or RT media activity privacy can change this behaviour. These plugins modify the activity clause and that could cause it to not work.

    Please check if you have any of these.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 46
    Kristian Yngve on #21321

    Hi Brajesh,

    Thanks for getting back to me about that.

    Firstly, about the plugins, I can confirm I don’t have BuddyPress wall, Facebook Like Activity Stream, activity privacy or RT media activity privacy installed.

    Buddypress plugins I do have are: BuddyPress, BP Force Profile Photo, BuddyPress NoCaptcha Register Box, BuddyPress Username Changer.

    —-
    But from reading your message very carefully, I think I have said wrong… what I was meaning, was to stop the user from appearing in the “Recently Active Members” widget in the sidebar.

    I think I should of explained better, and I am sorry for that.

    So, is that a different code all together that I need?

    Many thanks to you,

    Kristian

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #21342

    No problem.

    Thank you for creating the other topic. Let us handle that case there.

    Regards
    Brajesh

The topic ‘ [Resolved] Hiding activity for just one specific user’ is closed to new replies.

This topic is: resolved