does anyone know of way I can change the existing display name publicly as for all users. I want to have firstname lastname as the default because this will reflect in the forum. I have read all the forums and have tried all the hacks, any suggestions would be appreciated. Thanks in advance
Leave a Reply
You must be logged in to post a comment.
Here’s an improved version of richplane’s answer that works in newer versions of WordPress (3.8+):
Problem with using the admin_head hook is that it doesn’t work for users who don’t use the admin system. Also, my attempts to implement the solution posted by Marty failed because it doesn’t seem that the display_name can be updated by update_user_meta() – you have to use wp_update_user().
My proposal – put this in your functions.php file:
For me (using WP 3.4.1), that works OK, replacing the display name as soon as they log in.
A old question but my answer might be usefull for someone else.
Run this query on your database (adjust table names if you have another prefix):
UPDATE wp_users SET display_name = CONCAT((SELECT meta_value FROM wp_usermeta WHERE meta_key = 'first_name' AND user_id = ID), ' ', (SELECT meta_value FROM wp_usermeta WHERE meta_key = 'last_name' AND user_id = ID));
On WP 3.3.1 but should work on later versions.
use this code in function.php
this code juste for change display_name and replace with first_name plus first letter for last_name in step the new user or update info for user .
Quick and dirty hack would be to edit the file ‘wp-includes/user.php’ edit the folowing
Edit this line
Change to:
The above solution should work, assuming that the user.php file isn’t changed in a WordPress update or alternativly you could add something like this to your functions.php
but agian a few checks on this above could be added to see if the user is logged in, is an admin, contributor etc..etc..
but should do what your looking for..
Source: http://wordpress.org/support/topic/change-default-display-name-1
Marty