-
I think that’s right. Do you have an hint to solve this?
something like
automatic -> display name not filled = display name = full nameWhat you can do is to change this function
PHP12345678function set_default_display_name($user_id, $username) {$display_name = $username;if ($this->display_name_exists( $display_name )){$display_name = $this->unique_display_name($display_name);}wp_update_user( array( 'ID' => $user_id, 'display_name' => $display_name ) );update_user_meta($user_id, 'display_name', $display_name);}to make it use display_name = $full_name; instead! 🙂
How???
You see this line (which automatically sets display name as username)?
PHP1$display_name = $username;Remove the above line already and replace with
PHP12$full_name = userpro_profile_data('first_name',$user_id) . ' ' . userpro_profile_data('last_name',$user_id);$display_name = $full_name;Genius right? 😀 joking.. but that’s the logic behind it, if you really want display names to be DEFAULT to full name (Since you do not ask them for display name and just ask their email – which is their username)
That’s a core UserPro function, I am sorry you will need to backup api.php file for each update. The function is in /api.php it’s userpro function, not a theme function.
userpro/functions/api.php
Now, I have this
PHP123456789function set_default_display_name($user_id, $username) {$full_name = userpro_profile_data('first_name',$user_id) . ' ' . userpro_profile_data('last_name',$user_id);$display_name = $full_name;if ($this->display_name_exists( $display_name )){$display_name = $this->unique_display_name($display_name);}wp_update_user( array( 'ID' => $user_id, 'display_name' => $display_name ) );update_user_meta($user_id, 'display_name', $display_name);}But it doesn’t work. I’m doing something wrong?
News users created with this code, returns me numbers (21,84, ecc) as display names
Your code looks messed up because of forum…. maybe try this. if still you gettting crap-then man-please enable usernames. This code just uses first name + last name as display name. if you getting numbers then your users are not from earth ;D
/******************************************
Default display name
******************************************/
function set_default_display_name($user_id, $username) {
$full_name = userpro_profile_data(‘first_name’,$user_id) . ‘ ‘ . userpro_profile_data(‘last_name’,$user_id);
$display_name = $full_name;
if ($this->display_name_exists( $display_name )){
$display_name = $this->unique_display_name($display_name);
}
wp_update_user( array( ‘ID’ => $user_id, ‘display_name’ => $display_name ) );
update_user_meta($user_id, ‘display_name’, $display_name);
}Also if there is user with the same display anme-it will use name + last name + random 2 numbers
I need this too 🙂 and have the same issue, it returns me weird numbers, the do not match the user ID.
@Tomaso Greco did you get this to work?
thanks
You must be logged in to reply to this topic.