Events Made Easy › Forums › How do I … › How can I change what EME uses to set WP user name
Tagged: new user, WP_create_user
- This topic has 3 replies, 2 voices, and was last updated 1 year, 11 months ago by Franky.
-
AuthorPosts
-
Sat 24 Dec 2022 at 01:51 #64825AnonymousInactive
I think my solution would be similar to, but I am at a loss for how to modify and apply:
https://www.e-dynamics.be/wordpress/forums/topic/how-modify-eme_create_user-function/I have looked through settings and I cannot find where EME uses the first and last name of an RSVP set to create new users, I would like this to be set from a custom field for nickname or username.
I do not currently have a separate system for creating WP users but that is an option for me also, just makes new users being a 2 step process for events.PS. so far as I take each step through testing this, EME is working out to be a very complete system with great functions. I hope when I’m done configuring everything it will be the last event software I test.
Sat 24 Dec 2022 at 10:37 #64826FrankyKeymasterIt is in fact EME that creates a username based on firstname/lastname (also like wp does).
But in the thread you mention, you see an example:add_filter('eme_wp_userdata_filter','eme_my_wp_userdata_function'); function eme_my_wp_userdata_function($person){ $userdata=array(); $userdata['display_name']=$person['firstname'].' '.substr($person['lastname'],0,1); return $userdata; }
To change the username you’d need to set $userdata[‘user_login’], but in the current EME version that’s being ignored and overwritten by the EME generated username. This fixes it (only the change in eme-functions.php is needed):
https://github.com/liedekef/events-made-easy/commit/da2b7af0539ca676c821e6eeaf42fcf448b79a6a
Tue 27 Dec 2022 at 20:38 #64830AnonymousInactiveFranky,
Thank you for the quick reply. I have scrolled through many of the other documentation files. One thing I cannot find is an example using Custom Fields except for one example with event headers. Is this possible to do with other hooks and filters?I have a form that uses #_FILED{username} and I would like to use that input to create the WordPress Username. Username is a custom people field.
Tue 27 Dec 2022 at 23:42 #64834FrankyKeymasterOnce you have $person (in your filter), you can get the people-fields using something like:
$answers = eme_get_person_answers($person[‘person_id’]);
When you do a print_r on that, you’ll see the info 🙂
But just using the user input as username might not be ok. You can call the eme function eme_generate_unique_wp_username to assist in getting a good username. However, first apply https://github.com/liedekef/events-made-easy/commit/36309053be2f7e40335d89417b9fe763e46c78ce then 🙂Btw: do read this post: https://www.e-dynamics.be/wordpress/forums/topic/security-release/
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.