Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/9824d76fb9d44f6549af0ac0b39521b9 to your computer and use it in GitHub Desktop.
Save KaineLabs/9824d76fb9d44f6549af0ac0b39521b9 to your computer and use it in GitHub Desktop.
Add "In Group x" for Groups Sub Forums Posts
<?php
/**
* Add "In Group x" for Groups Sub Forums Posts
**/
function yzc_add_in_group_for_groups_sub_forums_posts( $activity_text, $user_id, $topic_id, $forum_id ) {
// Get Parent Forum
$parent_forum_id = bbp_get_forum_parent_id( $forum_id );
if ( empty( $parent_forum_id ) ) {
return $activity_text;
}
// Get Parent Forum Data.
$forum_permalink = bbp_get_forum_permalink( $parent_forum_id );
$forum_title = get_post_field( 'post_title', $parent_forum_id, 'raw' );
$forum_link = '<a href="' . $forum_permalink . '">' . $forum_title . '</a>';
// Edit Action Text.
$activity_text .= ' in the group ' . $forum_link;
return $activity_text;
}
add_filter( 'bbp_activity_topic_create', 'yzc_add_in_group_for_groups_sub_forums_posts', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment