Events Made Easy › Forums › How do I … › membership wp user
- This topic has 15 replies, 2 voices, and was last updated 4 years, 9 months ago by Anonymous.
-
AuthorPosts
-
Sat 15 Feb 2020 at 23:38 #60857AnonymousInactive
Hi there,
I am trying out the option “Create WP user after signup” with the membership option.
When I sign up with an email that is not in my wp users, nothing happens.. ? It doesn’t link to a wp user.. ? What am I missing?Sun 16 Feb 2020 at 00:18 #60858FrankyKeymasterJust tested it here: works fine … you need to make sure you’re not logged in as well at that time.
Sun 16 Feb 2020 at 01:53 #60859AnonymousInactiveHi Franky, I made a video to show you what I am experiencing.. Maybe you can see if I am doing something wrong..
VideoSun 16 Feb 2020 at 14:24 #60860FrankyKeymasterIn your video at 2:38 you see the user with name “Test test” and when you refresh you see the name changes. This means wordpress used that account, so I’m guessing you’re not really signed out … or something really weird is going on with the function eme_create_wp_user (in eme_functions.php). So maybe try starting debugging that function (but I don’t really see anything wrong there …)
Sun 16 Feb 2020 at 19:29 #60861AnonymousInactiveYeah, very strange.. I noticed that.. I have made another test just to see with another browser..
Another TestI would love to know what is happening here.. do I need to test on another machine all together?
Sun 16 Feb 2020 at 20:14 #60862FrankyKeymasterEME tries to be smart about the user … is there a new EME person created upon booking? If not, feel free to forward the page to me, I’ll test too. And if you want, some admin account to check would then be nice too
Sun 16 Feb 2020 at 22:15 #60864AnonymousInactiveIf you see the video there is a new EME person created when I book. The only thing is that is connects it to the admin user all the time.. ? I don’t mind sharing an admin user for you to have a look, but maybe I can send it to your email or something a bit more private? 🙂
Sun 16 Feb 2020 at 23:16 #60865FrankyKeymasterOMG … saying this made me realize something … I create the wp user, but never associate the member with the created user. I had the same issue in the past with RSVP and there I corrected it, but I forgot to correct it here. Give me 5 minutes to come up with a patch.
Edit: wrong hunch, it was unrelated to that 🙂Sun 16 Feb 2020 at 23:26 #60866FrankyKeymasterOk, it seems to be related to the function eme_create_wp_user (in eme_functions.php). The code there is:
$username=eme_generate_unique_wp_username($person['lastname'],$person['firstname']); // use register_new_user so the person gets a mail $user_id = register_new_user( $username, $person['email'] ) ; $userdata = array( 'ID' => $user_id, 'last_name' => $person['lastname'], 'first_name' => $person['firstname'] ); wp_update_user($userdata);
As you can see, wp_update_user is where the lastname and firstname change, and that for the userid created with register_new_user. The odd thing is that for you, that userid seems to be your admin userid every time. The weird thing is that I first create a new username based on lastname/firstname that shouldn’t exist in the db yet, and then call register_new_user with that username and the given email. Maybe there something is wrong …
Sun 16 Feb 2020 at 23:33 #60867AnonymousInactiveI’m not sure here but, you are using wp_update_user… should you not use wp_insert_user as the user is not there ?
Sun 16 Feb 2020 at 23:49 #60868FrankyKeymasterI call register_new_user, which acts as if the user registered from the frontend (and that calls wp_create_user, which again calls wp_insert_user). If you know a little php, I’d say to debug stuff in the function eme_create_wp_user: do a print_r on the generated username and see if it is ok, then do a print_r on the $user_id after the call to register_new_user and see if that’s ok. I’m guessing something goes wrong there and $user_id probably contains an error code, the print_r will show it then (and maybe do an exit after the print_r, to make sure nothing continues).
The next version will get that error code earlier on in the function and not try to update a wp user if so: https://plugins.trac.wordpress.org/changeset/2245292/Mon 17 Feb 2020 at 00:14 #60869AnonymousInactiveSo now I have changed the file eme_functions.php and added:
function eme_create_wp_user($person) { $username=eme_generate_unique_wp_username($person['lastname'],$person['firstname']); // use register_new_user so the person gets a mail print_r($username); $user_id = register_new_user( $username, $person['email'] ) ; print_r($user_id); exit('Exit....'); $userdata = array( 'ID' => $user_id, 'last_name' => $person['lastname'], 'first_name' => $person['firstname'] ); wp_update_user($userdata); if (!is_wp_error($user_id)) { if (!empty($person['phone'])) update_user_meta($user_id,'eme_phone', $person['phone']); // now link the wp user to the person eme_update_person_wp_id($person['person_id'],$user_id); return $user_id; } else { return 0; } }
When I run the registration it does not print anything… ? did I write something wrong?
Mon 17 Feb 2020 at 00:16 #60870AnonymousInactiveI have changed the file eme_functions.php like this:
function eme_create_wp_user($person) { $username=eme_generate_unique_wp_username($person['lastname'],$person['firstname']); // use register_new_user so the person gets a mail print_r($username); $user_id = register_new_user( $username, $person['email'] ) ; print_r($user_id); exit('Exit....'); $userdata = array( 'ID' => $user_id, 'last_name' => $person['lastname'], 'first_name' => $person['firstname'] ); wp_update_user($userdata); if (!is_wp_error($user_id)) { if (!empty($person['phone'])) update_user_meta($user_id,'eme_phone', $person['phone']); // now link the wp user to the person eme_update_person_wp_id($person['person_id'],$user_id); return $user_id; } else { return 0; } }
When I run the registration is does not show anything… ? did I write anything wrong?
Mon 17 Feb 2020 at 00:18 #60871FrankyKeymasterSeems ok to me, make sure no caching plugin is active though.
And if you want me to test it (tomorrow, too late now): liedekef@telenet.beMon 17 Feb 2020 at 09:35 #60874AnonymousInactiveThanks Franky, really appreciate your time.
Just sent you an email. -
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.