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

Daniel danielx386 at gmail.com
Mon Nov 18 00:08:38 UTC 2013


Hi Alex,

Thank-you for getting back to me,  now I take it that I should be able
to use the script that you provided (I know that it need some editing)
after I done the usual  "include '/../../../wp-load.php';"?

Also what should I do if the password is not in plain text? (I'm not
entirely sure if the "$password" is still alive at that point of the
script, it's going right after someone logged into phpbb, I will need
to check on that)

Having said that I will give it a go and see how I go :)

Thank-you again Alex :)

Regards,
Daniel






On Mon, Nov 18, 2013 at 10:55 AM, Alex Rayan <alexrayan69 at gmail.com> wrote:
> 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_pass'=>$plain_text_pass,
> 'user_login'=>$username,
> 'user_nicename'=>$url_friendly_name,
> 'user_email'=>$user_email,
> 'display_name'=>$display_name
> );
> $user_id = wp_insert_user($args);
>
> You can check a full list of arguments that you can pass here:
> http://codex.wordpress.org/Function_Reference/wp_insert_user
>
> 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,
> Alex
>
>
> 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
>>
> _______________________________________________
> 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