Using wordpress user accounts with an iOS app

Hey so I’m building an iOS app. The fist window is a login screen where people login using their login information from the wordpress blog.
I’ve considered xml-rpc but it doesn’t allow a registration from the phone.
Then I looked at using a RESTful api but I have no idea how to connect it to the wordpress db to check if the username and password are correct.
There are quite a few puling for wordpress that set up RESTful APIs but none of them appear to help with what I’m trying to do.

Any help would be very much appreciated!

Related posts

Leave a Reply

1 comment

  1. Figured out how to do it. You can do it with xml-rpc. Here’s the code I have in my request plugin if anyone ever needs it:

    function register_user($args){
    
        require_once( ABSPATH . WPINC . '/registration.php' );
    
    /* 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" );
    
    
    }