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
相关问题
- Display product ACF field value in Woocommerce tra
- Adding a custom button after add to cart button in
- How to add a “active” class to a carousel first el
- Setting custom order statuses as valid for payment
- change the font size in tag cloud
相关文章
- wordpress新增页面如何个性化设置
- select query in wordpress
- Get WooCommerce featured products in a WP_Query
- Woocommerce update shipping methods in checkout vi
- Change order status just after payment in WooComme
- Publishing or uploading failed. Error message: “Th
- Facebook Login With WP JWT Auth
- Wordpress development process
Here's an improved version of richplane's answer that works in newer versions of WordPress (3.8+):
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
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.
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.