Created
June 2, 2014 20:02
-
-
Save alloyking/a2df7957471d51e6178b to your computer and use it in GitHub Desktop.
xml-rpc example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Check if users can register. */ | |
| $registration = get_option( 'users_can_register' ); | |
| /* If user registered, input info. */ | |
| $userdata = array( | |
| 'user_pass' => esc_attr( $args[2] ), | |
| 'user_login' => esc_attr( $args[0] ), | |
| 'first_name' => esc_attr( "" ), | |
| 'last_name' => esc_attr( "" ), | |
| 'nickname' => esc_attr( "" ), | |
| 'user_email' => esc_attr( $args[1] ), | |
| 'user_url' => esc_attr( "" ), | |
| 'aim' => esc_attr( "" ), | |
| 'yim' => esc_attr( ""), | |
| 'jabber' => esc_attr( "" ), | |
| 'description' => esc_attr( "" ), | |
| 'role' => get_option( 'default_role' ), | |
| ); | |
| if ( !$userdata['user_login'] ){ | |
| $error = __('A username is required for registration.', 'frontendprofile'); | |
| return "user-invalid"; | |
| }elseif ( username_exists($userdata['user_login']) ){ | |
| $error = __('Sorry, that username already exists!', 'frontendprofile'); | |
| return "user-used"; | |
| }elseif ( !is_email($userdata['user_email'], true) ){ | |
| $error = __('You must enter a valid email address.', 'frontendprofile'); | |
| return "email-invalid"; | |
| }elseif ( email_exists($userdata['user_email']) ){ | |
| $error = __('Sorry, that email address is already used!', 'frontendprofile'); | |
| return "email-used"; | |
| } | |
| else{ | |
| $new_user = wp_insert_user( $userdata ); | |
| wp_new_user_notification($new_user, $user_pass); //send the user an email with the information | |
| return "success"; | |
| } | |
| update_user_meta( $args[0]->ID, 'setup', "0" ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment