Hello @khoramdelsaeed20 ,
Thanks for reaching out!
It looks like this plugin does exactly what you are looking for – Force First and Last Name as Display Name
Since this is not entirely WooCommerce related, you can post on the plugin’s support forum, if you have further queries.
Cheers 🙂
Hi there,
We’ve not heard back from you in a while, so I’m marking this thread as resolved.
Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.
Thank you 🙂
hi
this pluging does not work and has many problems
please if you can give me a code for this job
Hello @khoramdelsaeed20 ,
I am sorry to hear that the plugin did not work as expected.
Here is a similar discussion with some sample codes – https://wordpress.stackexchange.com/questions/67444/force-display-name-as-full-name
Please try one of them, I hope you will be able to make it work.
I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.
You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.
If you need a paid solution, you can consider taking help from one of our partner’s websites.
Thank you 🙂
hi
thanks again
i found a solution which works correctly , this is the code for those who want to use it
/**
* New user registrations should have display_name set
* to 'firstname lastname'. This is best used on the
* 'user_register' action.
*
* @param int $user_id The user ID
*/
function set_default_display_name( $user_id ) {
$user = get_userdata( $user_id );
$name = sprintf( '%s %s', $user->first_name, $user->last_name );
$args = array(
'ID' => $user_id,
'display_name' => $name,
'nickname' => $name
);
wp_update_user( $args );
}
add_action( 'user_register', 'set_default_display_name' );
Awesome!
I am glad to know that you have found the solution. I am sure someone else will find this useful as well. If you have any other queries, feel free to open a new thread.
Thank you 🙂