How to filter this block and update wp_create_user

Hi,

Is it possible to filter this block to update wp_create_user:

 $validation_error = apply_filters('registration_errors', $validation_error, $login, $mail);

            if (!$validation_error->get_error_code()) {
                $login = sanitize_user($login, true);
                $user_id = wp_create_user( $login, $password, $mail);
                $userd = get_user_by('ID', $user_id);

I would like to be able to modify the wp_create_user function runtime. So it would execute this:

$user_id = wp_create_user( $code ._. $login, $password, $mail);

At the moment this is hard-coded in the plugin.

Thanks for any tips.

Chris

Well, you can append a string to the login, yes, but i’m not sure I see the point in tacking a string in front of the user’s login, as they will need to then put that full string in when logging in.

Yes I understand why you’d wonder that. Basically the login is handled by SMS with the mobile number, the username is just being created in a way that the client wants to see it in the admin table.

In other words the user isn’t logging on with the username. The username just needs to be a country code, a underscore and the login which is the $login.

There may be a better way to do that, but at the moment I just wanted to see if i could do it this way, witha filter.

Thanks

Chris

Well, other than wrapping the underscore in quotes, your code should work as written.

Okay - yes it works but it’s hard coded, i want to update that block with that code but i don’t understand if it’s filterable.

Chris

Well, where does the plugin get its value for $login?

It’s from the mobile input field you choose your country code, input your mobile it send and sms you verify it and it creates the username, it’s the username I need to modify, it’s never used to log back into the site, since you always use your mobile and get a OTP code. I can easily do this, by hard-coding it but it would need to be filterable. I thought I might be able to hook into it with the add filter. This is what I’m not sure about!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.