Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Trying to alter layout of bp_activity_action()


Boone Gorges
Keymaster

@boonebgorges

It’s probably best to take a multi-faceted approach.

Instead of changing the way that content appears on the way out (by the time you call the global $activities_template, the content is already written in the db), you might consider manipulating it on the way in. Less overhead that way. For group related stuff like forum posts, open up bp-groups.php and search for uses of the function groups_record_activity. You’ll notice that the arguments for this function are almost always filtered. For instance, in the function groups_new_group_forum_post, you can modify the way that the activity action is displayed – you might do something like this in your theme’s functions.php:

function my_format_activity_action($activity_action, $post_id, $post_text, &$topic) {
$action = $post_text->topic_poster_name . " said:";
return $action;
}
add_filter( 'groups_activity_new_forum_topic_action', 'my_format_activity_action', 1, 4 );

That’s a lot easier than after-the-fact string manipulation, both for you as a developer and for the system that has to do the processing. Fish around in the files for other places where apply_filters appears – you can build functions like the one I lay out above for any filtered output.

As far as moving things around and putting them in different orders, you’ll definitely want to look at the activity/entry.php template file. That’s where all the markup appears, so any changes (like ordering and appearance) should happen there and in CSS.

And if you just want to change the wording here and there, you might also consider using language files (https://codex.buddypress.org/how-to-guides/customizing-labels-messages-and-urls/). It’s a relatively future-proof way to do customization.

Skip to toolbar