Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

Viewing 25 replies - 1 through 25 (of 27 total)
  • I want to show only status and groups updates!


    Henry Wright
    Moderator

    @henrywright

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

    Using bp_parse_args() to filter BuddyPress template loops

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

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


    Henry Wright
    Moderator

    @henrywright

    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.

    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???

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


    Henry Wright
    Moderator

    @henrywright

    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.

    Henry Wright
    Moderator

    @henrywright

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

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

    the updates are still showing in the activity stream.


    Henry Wright
    Moderator

    @henrywright

    Can you paste the code you’re using?

    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;
    } );

    Is right or not?

    it must be difficult

    key = array_search

    I think this is wrong…


    Henry Wright
    Moderator

    @henrywright

    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;
    } );

    that’s the only think i see different there:

    bool(false)


    Henry Wright
    Moderator

    @henrywright

    @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.

    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.


    Henry Wright
    Moderator

    @henrywright

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

    Hmm What line you add the code?


    Henry Wright
    Moderator

    @henrywright

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

    It worked for profile picture…
    But not for example:

    johns profile was updated

    or for comments

    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