Capitalize names in xprofile on input/signup
-
My first custom field_1 is for fullname. I want to capitalize that input. I already have a function that does that – nameize(). Where should I apply it?
I’ve gone through a lot of trouble to also update the full name in wp_usermeta and elsewhere upon activation, so those fields all have nicely formatted names.
But the display name is apparently stored in xprofile before activation. Where is the code that does that? Or is there a way to update the xprofile field with capitalized versions in the same custom function I use to update wp_usermeta?:
function synchro_wp_usermeta($user_id, $password, $meta) {
global $bp, $wpdb;
$uid = get_userdata($user_id);
$email = $uid->user_email;
$fullname = $meta[field_1];
$space = strpos( $fullname, ' ' );
$company = $meta[field_2];
if ( false === $space ) {
$firstname = $fullname;
$lastname = '';
} else {
$firstname = substr( $fullname, 0, $space );
$lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
}
$firstname = nameize($firstname);
$lastname = nameize($lastname);
$autousername = str_replace('-', '', str_replace("'", "", str_replace('.', '', str_replace(' ', '', strtolower($fullname)))));
update_usermeta( $user_id, 'nickname', $fullname );
update_usermeta( $user_id, 'first_name', $firstname );
update_usermeta( $user_id, 'last_name', $lastname );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_login = %s WHERE ID = %d", $autousername, $user_id ) );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_nicename = %s WHERE ID = %d", $autousername, $user_id ) );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $user_id ), $user_id ) );
}
add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);
- The topic ‘Capitalize names in xprofile on input/signup’ is closed to new replies.