[wp-hackers] Check to see if there a wordpress user account and create one if not outside of wordpress

Alex Rayan alexrayan69 at gmail.com
Sun Nov 17 23:55:40 UTC 2013

Hi Daniel,

I'm sorry I don't have time to go through your whole script, but to check
whether the user exists you can use:
if( !email_exists( $email )) {
and to pass email that you would like to check against.
Then if the email is not found in the database, you can create a new user
account as follows:

$args = array(
$user_id = wp_insert_user($args);

You can check a full list of arguments that you can pass here:

Also, it's probably a good idea to check for username_exists before passing
a username in case that one is already taken. Then, you could, for example,
append a number at the end of the username.

On success the function above returns user_id.

Hope it helps.

Best regards,

On Sun, Nov 17, 2013 at 5:34 PM, Daniel <danielx386 at gmail.com> wrote:

> Hi guys,
> Just wondering, does anyone know how I can go about checking to see if
> there a wordpress account and create one if there isn't?
> Script that I got: https://gist.github.com/Danielx64/7519092
> There a marker in the file that has "// Somewhere here I want to put a
> check to see if there a wp account" What I want to happen there is
> that a check get done to see if there is a wordpress account and if
> there not, create one.
> Does anyone know if it can be done?
> PS, I don't need to worry about logging into wordpress as that will
> get taken care of by a different script. Also anyone who can help me
> out will also get credit in the source code and readme :)
> Regards,
> Daniel
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list