BuddyDev

Search

[Resolved] Filtering the sitewide activity

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #6554

    I would like to filter the sitewide activity loop to only show blog updates. I used display:none with css, but that made it very buggy. Is there a code I can put in my functions.php? I was reading this site, but it seems outdated because the codes give me syntax errors. https://premium.wpmudev.org/blog/how-to-customize-the-buddypress-activity-loop/

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #6555

    <?php if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) . ‘&action=new_blog_post’ ) ) : ?>

    ^this gave me a syntax error and it is from the codex lol

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #6556

    I discovered the buddypress support lol. I found an answer that works for me. Here it is for others that may need it. Sorry 😛

    function bpex_bp_activity_types( $retval ) {
    if ( bp_is_active( ‘activity’ ) ) {

    // list of all BP activity types – remove or comment those you won’t show.
    $retval[‘action’] = ‘
    activity_comment,
    activity_update,
    // bbp_topic_create,
    // bbp_reply_create,
    friendship_created,
    created_group,
    joined_group,
    last_activity,
    new_avatar,
    new_blog_post,
    new_blog_comment,
    new_member,
    updated_profile
    ‘;

    return $retval;

    }
    }
    add_filter( ‘bp_after_has_activities_parse_args’, ‘bpex_bp_activity_types’ );

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #6557

    ^comment whatever you dont want in the activity stream by putting a // before it. For example I put // before everything except “new_blog_post”

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #6558

    Well this does it on all activity even on your personal profile. Is there a way to just keep this setting on ONLY the activity page?

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #6559

    Hi Chris,
    You can use the acondition

    
    if( ! bp_is_activity_directory()) {
    
    return $retval;
    }
    
    

    at the top of your function.

    Hope that helps.

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #6560

    Do I put that above everything? Sorry, I’m a php noob lol.

  • Participant
    Level: Enlightened
    Posts: 69
    Christopher Niedzwiecki on #6561

    This is the code I used and it worked. Thanks a lot for the help!!!!

    function bpex_bp_activity_types( $retval ) {

    if( ! bp_is_activity_directory()) {

    return $retval;
    }

    if ( bp_is_active( ‘activity’ ) ) {

    // list of all BP activity types – remove or comment those you won’t show.
    $retval[‘action’] = ‘
    //activity_comment,
    //activity_update,
    // bbp_topic_create,
    // bbp_reply_create,
    //friendship_created,
    //created_group,
    //joined_group,
    //last_activity,
    //new_avatar,
    new_blog_post,
    //new_blog_comment,
    //new_member,
    //updated_profile
    ‘;

    return $retval;

    }
    }
    add_filter( ‘bp_after_has_activities_parse_args’, ‘bpex_bp_activity_types’ );

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #6563

    You are doing well 🙂
    I am glad I could help a little bit.

    Marking ti as resolved.

    Regards
    Brajesh

The topic ‘ [Resolved] Filtering the sitewide activity’ is closed to new replies.

This topic is: resolved