Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to make activity Stream not showing profile or profile pictures updates?

  • @mlao

    Participant

    Hi
    Is there any way to make activity stream to not showing profile or profile pictures updates?

Viewing 25 replies - 1 through 25 (of 27 total)
  • @mlao

    Participant

    I want to show only status and groups updates!

    @henrywright

    Moderator

    This article is super valuable if you plan on filtering the activity loop:

    Using bp_parse_args() to filter BuddyPress template loops

    @mlao

    Participant

    Thanks anyway, but only I look at those codes I get headache…

    @mlao

    Participant

    If there is any of you has a ready code and info about where and how you add it, I will appreciate it…

    @henrywright

    Moderator

    To stop “profile photo updated” updates being displayed in your activity stream, try this:

    add_filter( 'bp_after_has_activities_parse_args', function( $retval ) {
        // Convert $retval['action'] into an array.
        $parts = explode( ',', $retval['action'] );
    
        // Remove new_avatar items.
        if ( ( $key = array_search( 'new_avatar', $parts ) ) !== false ) {
            unset( $parts[$key] );
        }
    
        // Convert $parts back into a comma separated string.
        $retval['action'] = implode( ',', $parts );
    
        return $retval;
    } );

    Please note I haven’t tested.

    @mlao

    Participant

    Wow your amazing…The code works. But is still showing in activity stream: (John) Profile was updated or (John) Become a register member… Is there anyway to not show those either???

    @mlao

    Participant

    Sorry I make a mistake. The code din’t work… It still show profile updates.

    @henrywright

    Moderator

    The code removes updates like “Ben changed his profile photo”. It doesn’t remove stuff like “Ben posted an update”. In the code you’ll see I’ve used new_avatar. That’s one particular action. Feel free to add more by adding another block. For example:

    // Rest of code here.
    
    // Remove new_avatar items.
    if ( ( $key = array_search( 'new_avatar', $parts ) ) !== false ) {
        unset( $parts[$key] );
    }
    
    // Remove another action.
    if ( ( $key = array_search( 'action_here', $parts ) ) !== false ) {
        unset( $parts[$key] );
    }
    
    // Rest of code here.

    @henrywright

    Moderator

    To add, I think updated_profile is the action you’re looking for.

    @mlao

    Participant

    Thank you for your time, but as I said before the code not working even for the profile photo.

    @mlao

    Participant

    the updates are still showing in the activity stream.

    @henrywright

    Moderator

    Can you paste the code you’re using?

    @mlao

    Participant
    add_filter( 'bp_after_has_activities_parse_args', function( $retval ) {
        // Convert $retval['action'] into an array.
        $parts = explode( ',', $retval['action'] );
    
        // Remove new_avatar items.
        if ( ( $key = array_search( 'new_avatar', $parts ) ) !== false ) {
            unset( $parts[$key] );
        }
    
    // Remove updated_profile.
    if ( ( $key = array_search( 'updated_profile', $parts ) ) !== false ) {
        unset( $parts[$key] );
    }
    
        // Convert $parts back into a comma separated string.
        $retval['action'] = implode( ',', $parts );
    
        return $retval;
    } );

    @mlao

    Participant

    Is right or not?

    @mlao

    Participant

    it must be difficult

    @mlao

    Participant

    key = array_search

    I think this is wrong…

    @henrywright

    Moderator

    Do you mind doing a little debugging for me? If you paste the following code into your theme’s functions.php file (make sure this is done on your testing install). Then visit the activity stream. You should see some output dumped on the screen. Can you copy that and paste it here?

    add_filter( 'bp_after_has_activities_parse_args', function( $retval ) {
        var_dump( $retval['action'] );
        return $retval;
    } );

    @mlao

    Participant

    that’s the only think i see different there:

    bool(false)

    @henrywright

    Moderator

    @mlao,

    Sorry for the delay in getting back to you. So it looks like we will need to add our actions instead of removing them. Here’s where the fun part begins. You’ll need to find a list of all the action types you want in your stream and add them to the following snippet:

    add_filter( 'bp_after_has_activities_parse_args', function( $retval ) {
        $retval['action'] = array(
            'activity_update',
            'activity_comment',
            'another_action_here_etc',
        );
        return $retval;
    } );

    Obviously, don’t include updated_profile or new_avatar.

    @mlao

    Participant

    Really, I don’t know why, but is not working…

    I add it like this in my themes faction.php

     add_filter( 'bp_after_has_activities_parse_args', function( $retval ) {
       $retval['action'] = array(
            'activity_update',
            'activity_comment',
            'updated_profile',
        );
        return $retval;
    } );
    

    but nothing works.

    @henrywright

    Moderator

    That’s strange, I just tested and it works fine for me?

    @mlao

    Participant

    Hmm What line you add the code?

    @henrywright

    Moderator

    I added it at the end of my theme’s functions.php file. I’m using Twenty Fifteen to test.

    @mlao

    Participant

    It worked for profile picture…
    But not for example:

    johns profile was updated

    or for comments

    @mlao

    Participant

    I did some changes and worked!!!! Thanks a lot!
    I think it was the position of the code…
    Is not working for comments, but no problem…

Viewing 25 replies - 1 through 25 (of 27 total)
  • You must be logged in to reply to this topic.
Skip to toolbar