Events Made Easy Forums How do I … membership wp user

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #60857
    Anonymous
    Inactive

    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?

    #60858
    Franky
    Keymaster

    Just tested it here: works fine … you need to make sure you’re not logged in as well at that time.

    #60859
    Anonymous
    Inactive

    Hi Franky, I made a video to show you what I am experiencing.. Maybe you can see if I am doing something wrong..
    Video

    #60860
    Franky
    Keymaster

    In 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 …)

    #60861
    Anonymous
    Inactive

    Yeah, very strange.. I noticed that.. I have made another test just to see with another browser..
    Another Test

    I would love to know what is happening here.. do I need to test on another machine all together?

    #60862
    Franky
    Keymaster

    EME 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

    #60864
    Anonymous
    Inactive

    If 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? 🙂

    #60865
    Franky
    Keymaster

    OMG … 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 🙂

    #60866
    Franky
    Keymaster

    Ok, 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 …

    #60867
    Anonymous
    Inactive

    I’m not sure here but, you are using wp_update_user… should you not use wp_insert_user as the user is not there ?

    #60868
    Franky
    Keymaster

    I 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/

    #60869
    Anonymous
    Inactive

    So 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?

    #60870
    Anonymous
    Inactive

    I 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?

    #60871
    Franky
    Keymaster

    Seems 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.be

    #60874
    Anonymous
    Inactive

    Thanks Franky, really appreciate your time.
    Just sent you an email.

Viewing 15 posts - 1 through 15 (of 15 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top