Get user id from email?

I’m working on an email system, and I’m onto the unsubscribing stage. Since most of my users would not know their user ID, I’m asking them to put their email into a text box (definitely preferred, since this IS an email system). In order to change their user meta (their subscribed status), I need to know the users ID. I mean I suppose I could pass it into an email and put it in the unsubscribe link, but I’m planning on sending out emails to people who don’t have wordpress accounts.

So my main question is this:

Read More

What logic or functions should I use to determine a users ID from an inputted email address, and if none are found, store them in the wordpress database?

Thanks, I appreciate every answer!!

Related posts

Leave a Reply

3 comments

  1. You are probably looking for the user_exists function. http://codex.wordpress.org/Function_Reference/email_exists

    This function will check whether or not a given email address ($email) has already been registered to a username, and returns that users ID (or false if none exists).

    If the email address does not exist (user_exists returns false), you may want to use the wp_create_user function. http://codex.wordpress.org/Function_Reference/wp_create_user

    The wp_create_user function allows you to insert a new user into the WordPress database

    Only do that if you want to create a WordPress user though, which you may or may not. I’m a bit confused by this part of the question.

  2. You can only get this email and verify if there is any user have this email then change this email by the correspond username
    like this

    $login ='anything@me.com';
    if(is_email( $login )){
                if( email_exists( $login )) {
                  $userID__ = email_exists($login);
                  $user_info_kim = get_userdata($userID__);
                  $login  = $user_info_kim->user_login;
                }
            }