Last active
July 26, 2022 14:51
-
-
Save KaineLabs/6f86315ba12123ebcf461f71923d0782 to your computer and use it in GitHub Desktop.
Disable Buddypress Name Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change Name field With Username. | |
*/ | |
function my_member_username() { | |
global $members_template; | |
return $members_template->member->user_login; | |
} | |
add_filter( 'bp_member_name' , 'my_member_username' ); | |
/** | |
* Change FullName field With Username. | |
*/ | |
function my_bp_displayed_user_fullname( $fullname ) { | |
if ( ! bp_is_user() ) { | |
return $fullname; | |
} | |
global $bp; | |
return isset( $bp->displayed_user->userdata->user_login ) ? $bp->displayed_user->userdata->user_login : $fullname; | |
} | |
add_filter( 'bp_displayed_user_fullname' , 'my_bp_displayed_user_fullname' ); | |
/** | |
* Header Script | |
*/ | |
function yzc_sync_username_and_name_fields() { | |
?> | |
<script> | |
var url = document.location.href; | |
jQuery(document).ready( function() { | |
//copy profile name to account name during registration | |
if ( url.indexOf( "register/" ) >= 0 ) { | |
jQuery( 'label[for=field_1],#field_1' ).css( 'display', 'none' ); | |
jQuery( '#signup_username' ).blur( function() { | |
jQuery( '#field_1' ).val( jQuery( "#signup_username" ).val()); | |
}); | |
} | |
}); | |
</script> | |
<style type="text/css"> | |
#profile-details-section .logy-section-title, | |
.editfield.field_1 { | |
display: none; | |
} | |
</style> | |
<?php | |
} | |
add_action( 'wp_head', 'yzc_sync_username_and_name_fields' ); |
Changing line 18 from
return $members_template->member->user_login;
to
return $bp->displayed_user->fullname;
cleared the error for me. Hopefully that still works with everything.
Changing line 18 from
return $members_template->member->user_login;
to
return $bp->displayed_user->fullname;
cleared the error for me. Hopefully that still works with everything.
Sorry for the late reply i just saw your message, done i updated the code.
I get the following error with this code
An invalid form control with name='field_1' is not focusable.
I'm getting this error:
"An invalid form control with name='field_1' is not focusable"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get the following error with this code