Hi, on my website, the e-mail addresses of the users are automatically stored as user names in my member area. It has to stay that way. Of course, the e-mail addresses can not be displayed publicly if someone is to be mentioned (data protection). But that's how it is at the moment. Can I set it to only show the NAME?
Paid Addons Support Forum Only
Please note, that here we only support Paid Addons issues and questions.
gVectors Support staff works from 6am to 6pm (GMT+0)
All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:
The email address is the username - how to force names?
Hi Mary Mattiolo,
Please don't confuse Username and Nicename. Those are not the same.
Nicenames are used for user @mentioning and in your profile URL. So again, this is the nicename, not username.
If you want to disable the wpDiscuz mentioning feature at all, you should disable the "User Mentioning" option. It's located in the Dashboard > wpDiscuz > Settings > Subscription and User Following admin page.
More info here: https://wpdiscuz.com/docs/wpdiscuz-7/plugin-settings/subscription-and-user-following/#enable-user-mentioning
In any case, if you just want to hide the nicename, but allow people to @menation each other, you should put this code in WordPress active theme functions.php file.
add_filter("wpdiscuz_show_nicename", "__return_false");
This article should be helpful for you: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/
Important: The code above just hides the nicename next to the display name, but the mentioning feature will be still available if the users know the nicenames of each other.
Yes, that's all clear to me. However, when mentioned on my website, the e-mail addresses appear …
Screenshots:
The screenshots are missing, please attach those, to allow us to better understand the question.
The „preview icons“ are working when you click on it.
@astgh Actually I cannot use this addon because the problem persists. Can you please help?
Dear Mary Mattiolo,
As it is already mentioned, the wpDiscuz uses Nicename for mentioning. In your case, the mentioning Nicename and the Username are the same and those are email addresses. WordPress uses the same logic.
The only thing we can suggest you is to update the Nicename and set it different than the username
UPDATE `wp_users` SET `user_nicename` = 'X' WHERE `user_nicename` = `user_email`
In the code above you should change the red marked value and set the Nicename as you like.
The code will replace the Nicename where the Nicename is the email address of the users.
Important: if you change the Nicename you should make sure it has the same validation as a user_login, otherwise the mentioning feature won't work.
@astgh Excuse me, but are you saying I should manually change each individual user, with the code? That would definitely not be feasible with so many users...?
No, the code allows you to set the value for every user with email and nicename are the same, you can set it, for example, the user id or something else. You should decide for yourself what exactly it should be.
@astgh I'm sorry but your explanations don't make any real sense. You write here: https://gvectors.com/forum/wpdiscuz-user-comment-mentioning/the-email-address-is-the-username-how-to-force-names/#post-32577
But my users don't have an email address in the URL. Instead - as you wrote and correctly - the NICENAME.
Posted by: @astghNicenames are used for user @mentioning and in your profile URL. So again, this is the nicename, not username.
Dear Mary Mattiolo,
Nicenames are used for user @mentioning and in your profile URL. So again, this is the nicename, not username.
This means, you don't have a plugin that has frontend profile plugin that uses the nicename in the profile URL.
The solution provided will work fine: https://gvectors.com/forum/wpdiscuz-user-comment-mentioning/the-email-address-is-the-username-how-to-force-names/#post-32589
@astgh OK. And what exactly has to be there instead of the red X? Can you give me the exact code there?
Dear Mary Mattiolo,
You should decide for yourself what exactly you need to use instead of the email. You can use, for example, the user ID instead of the nicenames where it is the email address.
@astgh I'm aware … If I want to use the name, what value do I have to put in? Not the username, but the name of the respective person (see screenshot).
The names can't be used as far as there is a space between two words. It's not allowed. Besides, the display name is not unique and can't be used as mentioning nicenames.
Important: if you change the Nicename you should make sure it has the same validation as a user_login, otherwise the mentioning feature won't work.
@astgh As I explained before … I need the e-mail-addresses as user-names. I can't change them, otherwise my membership plugin won't work anymore because the e-mail-address is used for the login … so in this case, there is no solution to bring the mention feature to work on my site?
@astgh Ok, so when I use the code to change the nicenames to the user ID, which value has to be instead of "X"?
UPDATE `wp_users` SET `user_nicename` = 'X' WHERE `user_nicename` = `user_email`
The X should be replaced with the ID, that is:
UPDATE `wp_users` SET `user_nicename` = 'ID' WHERE `user_nicename` = `user_email`
Please make a backup of your database before you do any operations.
@astgh When I insert the exact following code
UPDATE 'wp_users' SET 'user_nicename' = 'ID' WHERE 'user_nicename' = 'user_email'
, I become the error: syntax error, unexpected single-quoted string "wp_users"
try this one:
UPDATE `wp_users` SET `user_nicename` = `ID` WHERE `user_nicename` = `user_email`
Then remove the '`' symbol from the code.
UPDATE wp_users SET user_nicename = ID WHERE user_nicename = user_email
@astgh ehm, sorry, but do you think I'm dumb? I have exactly done whatever you told me to you with the codes you gave me. I copied them 1:1, and they don't work … When I remove the " ' " the same error as before occurs again …
syntax error, unexpected identifier "wp_users"
The only reason, why I bought all! of your add-ons was, that this feature works.
Please record some videos where we can see how you're adding the code.
This is an SQL code. Please open phpMyAdmin Database manager of your hosting service > cPanel, navigate to WordPress database, press on SQL Tab and execute the query.
Helpful article: https://www.servercake.blog/run-sql-queries-using-phpmyadmin/
Don't forget about this.
Please make a backup of your database before you do any operations.
Helpful article: https://backwpup.com/docs/wordpress-database-backup/
@astgh omg … because of your post here: https://gvectors.com/forum/wpdiscuz-user-comment-mentioning/the-email-address-is-the-username-how-to-force-names/#post-32577
I thought this is just another snippet. 🤦♀️
Alright, then I know what to do. Just to be sure: Which of the three codes above should I use now. The first one?
UPDATE `wp_users` SET `user_nicename` = 'ID' WHERE `user_nicename` = `user_email`
Could you please send the admin login details to info[at]gvectors.com email address?
We've simply run the SQL code but made a few changes there. The Display Name is also needed to be updated.
For the future and new users, it will also work?
You should add the following PHP code in the active theme functions.php file:
add_action('user_register', function($user_id) { $register_user = get_user_by('ID', $user_id); if($register_user->user_email == $register_user->display_name){ wp_update_user(array( 'ID' => $user_id, 'user_nicename' => $user_id, 'display_name' => $user_id )); } });
I saw right now, that the mentioning not works for all users
We don't see such an issue on your website. Please watch this video: https://www.screencast.com/t/qA7Cuw58
Please delete the browser caches before checking.
The user ID is set as a value of the nicename in the case the user has an email address as its value. So the current user isn't listed there. That is in the Database the user ID is set as a user nicename.
If you use the ID it'll be listed fine.
Sorry, but I don't understand what you mean. I thought the problem was solved now? I just want all users to be able to mark themselves (in compliance with data protection regulations) with their names ... in such a way that it will continue to work for everyone in the future, as new customers register regularly.
The code we've provided you solves the problem you have. It replaces the user nicenames (where it sets the email addresses) with the user IDs. This works with the new users as well. If one of the newly registered users have the email address as a nicename it'll be replaced with the ID.
Latest Post: How to show all articles and news from the author in his profile? Our newest member: UG1881 Situs Agen Slot Tergaco... Recent Posts Unread Posts Tags
Forum Icons: Forum contains no unread posts Forum contains unread posts
Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed