Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Filter of Function / Theme or Plugin (5 posts)

Started 1 year, 8 months ago by: Matthew Holt

  • Profile picture of Matthew Holt Matthew Holt said 1 year, 8 months ago:

    I am new to BuddyPress Wordpress development and believe there is a solution to the workaround I have created and am looking for insight.

    I have altered the format of the activity output through the core bp plugin in bp-activity/bp-activity-template.php at the function bp_activity_action(). All that was done is a reformatting of the activity from a straight line output to a stacked output for group and document posts.

    It seems that this should be a filter application but am not sure if I must create a plugin in order to add a new filter or if I can add and apply the filter in my theme somewhere.

    Thanks in advance.

  • Profile picture of Boone Gorges Boone Gorges said 1 year, 8 months ago:

    I’m not sure what you mean by reformatting “to a stacked output”, but you can definitely modify the output of bp_activity_action() without modifying the core BP files. In your theme’s functions.php, try a function like the following:

    function holt_modify_action( $action, $activity ) {
        // $action is the unmodified action text produced by BP.
        // $activity is a structured object with information about the activity
        // Use those two values to concatenate whatever value you'd like, and then return it like this:
        return $my_action;
    }
    add_filter( 'bp_get_activity_action', 'holt_modify_action', 10, 2 );
  • Profile picture of Matthew Holt Matthew Holt said 1 year, 8 months ago:

    This was exactly what I was looking for @boonebgorges. That approach is perfect. As for a “stacked output,” we stacked the output activity as opposed to keeping it inline eg.
    default =
    [user] posted and update in the group [group name]
    stacked=
    User: [user]
    Group: [group name]

    Thank you again.

  • Profile picture of Boone Gorges Boone Gorges said 1 year, 8 months ago:

    Cool. Glad it works!

  • Profile picture of chouxpastry2002 chouxpastry2002 said 1 year, 7 months ago:

    hello sir,

    Can you please guide me how to use this function to filter ‘user joined’ and ‘user created’ a group from groups activity.

    Awaiting your response.

    Sam.