/*Reverse sticky header*/
  1. Home
  2. Knowledge Base
  3. Customizations
  4. CSS
  5. Change the Member Role Label on the Forum Replies to Profile Field Data

Change the Member Role Label on the Forum Replies to Profile Field Data

By default, we do not have this option. You can use the following function code. Please see the steps below:

Note: Make sure to have a complete site backup before proceeding

    1. Go to Appearance – Theme Editor.

    2. Under “Select theme to edit,” choose “BuddyBoss Child” or “whatever theme is active,” then click Select.

    3. Below Theme Files, select Theme Functions (functions.php).

    4. Append the code just before the closing PHP tag “?>”:

add_filter( 'bbp_get_reply_author_role', 'bb_replace_role_to_profile_field', 10, 2 ); function bb_replace_role_to_profile_field( $author_role, $args ) { $reply_id = bbp_get_reply_id( $args['reply_id'] ); $user_id = bbp_get_reply_author_id( $reply_id ); $profile_field = bp_get_profile_field_data( array( 'field' => 21, 'user_id' => $user_id ) ); if( $profile_field ) { $profile_field = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $args['before'], esc_attr( $args['class'] ), esc_html( $profile_field ), $args['after'] ); return $profile_field; } return $author_role; }

PHP

    5. Replace the ‘field’ => 21 with your field ID. (Check the below guideline on how to get the field ID)

    6. Click “Update File” to save the changes.

Note: Any modifications are considered custom work already. Know more about our Support Policy here: https://www.buddyboss.com/support-policy/

How to get the Profile Field ID:

  1. Edit the particular field from BuddyBoss->Profiles->Profile Fields.
  2. In the URL, you can copy the number next to field_id=
Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support

To speak to our Agency consultant, fill in the form found at our Contact Page.

"*" indicates required fields

Get Started

Enter your name and email address to get started with your project...

Name*