Support » Plugins » editing login with ajax plugin to include registration

  • Has anyone attempted this? I’m trying to get Login with AJAX to include handling the registration as well. i see this in the php file

    // Reads ajax login creds via POSt, calls the login script and interprets the result
    	function login(){
    		$return = array(); //What we send back
    		$loginResult = wp_signon();
    		$user_role = 'null';
    		if ( get_class($loginResult) == 'WP_User' ) {
    			//User login successful
    			/* @var $loginResult WP_User */
    			$return['result'] = true;
    			//Do a redirect if necessary
    			$data = get_option('lwa_data');
    			$user_role = array_shift($loginResult->roles); //Checking for role-based redirects
    			if( isset($data["role_login"][$user_role]) ){
    				$return['redirect'] = $data["role_login"][$user_role];
    			}else if($data['login_redirect'] != ''){
    				$return['redirect'] = $data['login_redirect'];
    		} elseif ( get_class($loginResult) == 'WP_Error' ) {
    			//User login failed
    			/* @var $loginResult WP_Error */
    			$return['result'] = false;
    			$return['error'] = $loginResult->get_error_message();
    		} else {
    			//Undefined Error
    			$return['result'] = false;
    			$return['error'] = 'An undefined error has ocurred';
    		//Return the result array with errors etc.
    		return $return;

    Now I’m assuming i can create a new function called ‘register’ and pretty much use code as a starter. My first stumbling block is trying to figure out how to get it to determine if the registration was successful or not. At first, I assumed i would change $loginResult = wp_signon(); to $loginResult = wp_register(); but i’m not sure if that returns anything on a successful registration, and if it does what does it return? not finding much info in the codex on this topic, so i’m hoping someone can help me out!

Viewing 1 replies (of 1 total)
  • OK…thanks to no one at wordpress…

    if ( get_class($chLogin) == ‘WP_User’ || is_user_logged_in() ) {

    does the trick

    hope that helps dpcdesigns

Viewing 1 replies (of 1 total)
  • The topic ‘editing login with ajax plugin to include registration’ is closed to new replies.