Skip to:
Content
Pages
Categories
Search
Top
Bottom

documentation for remove_action activity streams


  • djsteveb
    Participant

    @djsteveb

    I’ve seen a couple examples in some comments, like:

    To prevent new entries, try adding this to your theme functions.php
    remove_action( ‘bp_register_activity_actions’, ‘friends_register_activity_actions’ );

    Can someone add a page to explain for examples,maybe a list of things can be blocked and the underscored code for each?

    One bp install I am using I current set the old ‘block activity strames’ plugin to block

    friendship_created, blogpost_liked, new_member, joined_group

    but I’d like to block “changed profile picture” as well
    (it would REALLY awesome to allow one instance of changed profile picture to show in stream, but have something determine that profile pic was changed more than once in last 24 hours, then only show one instance (instead of the dozen added activity “UserX changed profile pic a dozen times)

    My old non-updated version of buddypress activity block shows these options:

    updated_profile
    new_blog_comment
    new_blog
    rtmedia_update
    friendship_created
    blogpost_liked
    joined_group
    created_group
    activity_liked
    new_avatar
    bp_album_picture
    new_member
    new_blog_post

    I am not sure if this is what could/should be added / append to the code that Shanbp had suggested above, and if so how.

    Going back through old threads, I see that there was a post about:

    Recently introduced function bp_parse_args allows since 2.0 to modify easely your templates. Faster and lighter than a plugin.

    Is the parse args better, or is that older and the current preferred method is to use a them functions.php?

    Is one lighter on resources than the other..
    …confused and not sure what method to use, and how to properly use it.

Viewing 9 replies - 1 through 9 (of 9 total)

  • Henry Wright
    Moderator

    @henrywright

    That’s a good idea. If you do a search for bp_activity_add() you will see everything that creates an activity item. Some plugins use the activity stream so be sure to search any of those you may have installed as well.


    djsteveb
    Participant

    @djsteveb

    I’d love to see some documentation on the ways to use this function..

    I’m having to retire the old “activity block plugin”

    So I guess code should be added to them functions.php… and this is more lightweight than doing a plugin or something in bp-custom? Not as easy to change main themes this way – but I prefer lighter loads with extra dev notes than heavier loads for easier to re-theme once every so many years..

    with activity block I have currently set to “disallow”
    deleted_group_document, new_blog, new_member, joined_group, friendship_created, activity_liked

    What would be the code needed to put in the theme function to block these things with how bp stuff is setup these days?

    remove_action( 'bp_register_activity_actions', 'friends_register_activity_actions', 'bp_blogs_format_activity_action_new_blog', 'bp_groups_format_activity_action_joined_group' );

    I checked hooker io and I do not see any info about friendship created, deleted_group_document, activity liked…

    I am guessing that old code “new_blog” is replaced by “bp_blogs_format_activity_action_new_blog” for current bp stuff.. ?

    “joined_group” = “bp_groups_format_activity_action_joined_group” ?
    “new_member” = “bp_members_format_activity_action_new_member” ?
    friendship created = ?
    deleted_group_document = ?
    activity liked = ?

    would adding “bp_xprofile_format_activity_action_new_avatar” stop the flood of activity showing when someone changes profile pic 10 times in an hour?


    Shaktimaan
    Participant

    @umar007

    I would also like to remove friendship activity. Any solution?


    danbp
    Participant

    @danbp

    @djsteveb,

    i wouldn’t remove the whole action hook, as other functionnalities from other plugins, can use it. Filtering is even better.

    bp_parse_{component}_args is intended to filter template loops.

    If you remove an {activity} type with this function, it will remove that activity from each activity feed (swa, profile and group). Something like an all or nothing thing.

    bp_parse return values. So if you want to remove something, you have to list what you want to keep to show, and not what to remove !

    Here a snippet, listing all existing BP activity types (2.2.x). Simply comment or remove the type you don’t want.

    function my_bp_activity_types( $retval ) {
    // list of all BP activity types  - remove or comment those you won't show.
        $retval['action'] = array(        
            'activity_comment',
    		'activity_update',
    		'created_group',
    		'friendship_created',
    		'joined_group',
    		'last_activity',
    		'new_avatar',
    		'new_blog_comment',
                    'new_blog_post',
    		'new_member',
    		'updated_profile'        
        );
     
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activity_types' );

    IMPORTANT: copy/paste to bp-custom.php or child-theme functions.php. Used as-is will do nothing ! You have to remove the type you don’t want from the list….

    Third party plugins (like bbPress) use also activity types. Easiest way to get the right type name is to check xxxx_bp_activity table in DB and search for it in the Type column.


    @umar007
    , removing friendship_created will solve your question.

    @djsteveb
    , remove new_avatar ! 😉


    Shaktimaan
    Participant

    @umar007

    Thanks @danbp

    It works. I am also using bbpress. I found these activity types created by bbpress in DB and added them to code given by you.

    bbp_topic_create
     bbp_reply_create

    danbp

    As mentioned by you also it may be confusing for some users and may cause problems in some situations , if someone is using a plugin like rtMedia that also creates activities.

    Can you share a code that will let us just remove unwanted activity type?


    danbp
    Participant

    @danbp

    @umar007,

    i already shared what is necessary to remove an activity. :smirk:

    $retval['action'] = array( 'type_name' );

    I don’t know type names of all existing plugins, reason why i told about DB.


    Shaktimaan
    Participant

    @umar007

    @danbp

    I have noticed a problem that is related to this code.

    I can’t sort/filter activity on mydomain.com/activity/ or any other page where this box/option is available. If i remove code, it starts working.


    danbp
    Participant

    @danbp

    @umar007, it’s not a problem, it’s how it’s intended to work. 😉

    Above snippet handles the activity output, not the activity filters. I wrote also it’s a kind of all or nothing thing….
    Understand that if you have, for example, an activity wall showing only updates and posts, you can’t filter this wall by new member or profile information. You can’t filter what you deactivated !

    You can use another approach, by adding eventually other filters or use a specific scope on the template, for example updates, which will show by default an activity wall of only updates, but where users can get all other activities if they use the one or other avaible filter.

    As example, try:

    
    function my_bp_add_custom_activity_dropdown_filter() {
    
    //This filters the activity loop by new blog posts, blog comments and forum topics.
    
            $types = 'new_blog_post,new_blog_comment,bbp_topic_create,new_forum_topic'; 
    ?>
     
            <option value="<?php esc_attr_e( $types ); ?>">New Content</option>
     
    <?php
    }
    add_action( 'bp_activity_filter_options', 'my_bp_add_custom_activity_dropdown_filter' );

    Hope to be clear. 😉


    whoaloic
    Participant

    @whoaloic

    Hello,
    I would like to remove options in the select dropdown.
    Anybody could help me?
    Regards.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘documentation for remove_action activity streams’ is closed to new replies.
Skip to toolbar