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:
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!!
You are probably looking for the
user_exists
function. http://codex.wordpress.org/Function_Reference/email_existsIf the email address does not exist (
user_exists
returnsfalse
), you may want to use thewp_create_user
function. http://codex.wordpress.org/Function_Reference/wp_create_userOnly 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.
Couldn’t you use: http://codex.wordpress.org/Function_Reference/get_user_by
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