I would like to see more improvements regarding the registration page where users can show/hide their real names. Is this possible out of the box without plugins?
@jessicana,
The field NAME in the field group BASE is required. This group is used for the registration page to work. As you already know, it’s also this group who allows you to show custom fields on the registration page.
The NAME field in BuddyPress is intended to receive first and last name and replace the two original fields (first name, last name) coming with WordPress.
That said, you can hide this field to users, but you can’t give them the choice to show/hide it.
The above snippet will hide the field NAME to all visitors/members, but not to site admin and the concerned profile.
function bpfr_make_name_members_only( $retval ) {
//hold all of our info
global $bp;
// is xprofile component active ?
if ( bp_is_active( 'xprofile' ) )
// The user ID of the currently logged in user
$current_user_id = (int) trim($bp->loggedin_user->id);
// The author that we are currently viewing
$author_id = (int) trim($bp->displayed_user->id);
// user can see only his name && admin can see everyone
if ($current_user_id !== $author_id && !current_user_can('delete_others_pages') ) {
$retval['exclude_fields'] = '1';
}
return $retval;
}
add_filter( 'bp_after_has_profile_parse_args', 'bpfr_make_name_members_only' );
Add this to your child-theme functions.php or to bp-custom.php