Replace BuddyPress Group as Community or something else

For replacing Group with other name like Community, team etc, there is more than one solution.

  1. Update it using Language file
  2. Update it using template override and lot’s of filter
  3. Using ‘gettext’ filter

I prefer to go with ‘gettext’ filter, It is the easiest way to do.

function smartcom_replace_group_labels( $text ) {

   // this code help to replace group label only in frontend
   if ( true === is_admin() ) {
      return $text;
   }

   $text = str_replace( 'Groups', 'Communities', $text );
   $text = str_replace( 'Group', 'Community', $text );
   $text = str_replace( 'groups', 'communities', $text );
   $text = str_replace( 'group', 'community', $text );
   return $text;
}
add_filter( 'gettext', 'smartcom_replace_group_labels' );
add_filter( 'ngettext', 'smartcom_replace_group_labels' );
add_filter( 'gettext_with_context', 'smartcom_replace_group_labels' );
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s