Hello great team 🙂
In my set up i have a Xprofile Field Group with title ‘Settings’ and group id 2.
What i am trying to do is to set a different title for this profile group according to the user role.I would like to ask you for your help in the below code please:
add_filter( 'xprofile_filter_profile_group_tabs', 'conditional_profile_group_name' ); function conditional_profile_group_name( $group_name ) { if ( $group_id = 2 && bp_current_user_can( 'subscriber' )) { $group_name = 'Settings1'; } elseif ( $group_id = 2 && ( bp_current_user_can( 'contributor' ) || bp_current_user_can( 'editor' ) ) { $group_name = 'Settings2'; } return $group_name; }
I have tried this but doesn’t seem to work 🙁
Could you please give me some help?
Thank you very much for your time
Hi,
You are using incorrect filter.Please use the filter ‘bp_get_the_profile_group_name’.
Also, group id is not available with this filter.
Regards
BrajeshHello Brajesh,
Thank you for your help 🙂
I made this:
add_filter( 'bp_get_the_profile_group_name', 'child_update_profile_group_name' ); function child_update_profile_group_name( $name ) { global $group; if ( $group->name == 'Settings' && bp_current_user_can( 'subscriber' ) ) { $name = 'Settings1'; } return $name; }
since there is no group id available, but still don’t work 🙁
Any ideas how i can target the group?
Please use this example. In the above code, you are using $group object which si not available.
function child_update_profile_group_name( $name ) { if ( $name == 'Settings' && is_user_logged_in() && in_array( 'subscriber', wp_get_current_user()->roles ) ) { $name = 'Settings1'; } return $name; } add_filter( 'bp_get_the_profile_group_name', 'child_update_profile_group_name' );
Regards
Brajesh
The topic ‘ [Resolved] Override Xprofile Group Name with role conditions’ is closed to new replies.