This topic has 7 replies, 2 voices, and was last updated 8 years by sharmstr.

  • Author
  • #97996
     yourateporn
    Participant

    Hello,

     

    I want to put this code in my theme but dont know how.

    //Block certain activity types from being added
    function bp_activity_dont_save( $activity_object ) {
    $exclude = array(
    ‘updated_profile’,
    ‘new_member’,
    ‘new_avatar’,
    ‘friendship_created’,
    ‘joined_group’
    );
    // if the activity type is empty, it stops BuddyPress BP_Activity_Activity::save() function
    if( in_array( $activity_object->type, $exclude ) )
    $activity_object->type = false;
    }
    add_action(‘bp_activity_before_save’, ‘bp_activity_dont_save’, 10, 1 );

     

    #98000
     sharmstr
    Moderator

    It goes in your child theme’s functions.php file. If you’re not running a child theme (which you should be), you can use a bp-custom.php. More information on that can be found on the buddypress website: https://codex.buddypress.org/themes/bp-custom-php/

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #98010
     yourateporn
    Participant

    Thnx, but i doing something wrong?

    I make a new php file and call it:
    bp-custom.php

    I put the code in it like this:
    <?php
    //Block certain activity types from being added
    function bp_activity_dont_save( $activity_object ) {
    $exclude = array(
    ‘updated_profile’,
    ‘new_member’,
    ‘new_avatar’,
    ‘friendship_created’,
    ‘joined_group’
    );
    // if the activity type is empty, it stops BuddyPress BP_Activity_Activity::save() function
    if( in_array( $activity_object->type, $exclude ) )
    $activity_object->type = false;
    }
    add_action(‘bp_activity_before_save’, ‘bp_activity_dont_save’, 10, 1 );
    ?>

    But its not working

    #98011
     sharmstr
    Moderator

    It wont remove those activities if they were added before you created the file. It will only stop new activities from being recorded. Is that the issue? If not, explain it better.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #98013
     yourateporn
    Participant

    I test it right now, cancel friendship, and make friends again. But it shows up in the activety

    #98015
     sharmstr
    Moderator

    where did you put bp-custom.php?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #98016
     yourateporn
    Participant

    I get it, its working now. I use the code i put in here. But the code changes when i put it in here. Sorry

    And thnx for helping me out. And sorry for my bad english 🙂

    #98019
     sharmstr
    Moderator

    No problem. Glad its working.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘Plugins questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?