• Resolved Marc1205

    (@marc1205)


    Hey Teodor,

    when I click on the link in the mail I get to the My Profile site, is it possible to create a link that sends me to a different page in the frontend ?

    thanks,
    Marc

    • This topic was modified 9 years, 2 months ago by Marc1205.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello Marc,

    Unfortunately we don’t have this feature inside Passwordless Login. I added your request in our Feature Requests List.

    This means that in the future the dev team will implement this functionality.

    I am sorry but until then I don’t have a solution for your request.

    I will mark this thread as resolved.

    Best regards,

    Just wanted to weigh in that this feature would be fantastic. For the site I’m hoping to use this on, bringing people to the home page after they log-in is critical. Is there a way to do this in the short-term by altering the code?

    Thread Starter Marc1205

    (@marc1205)

    Hi Steven,
    this may not be most elegant way, but I achieved this by just adding the URL I want the user to see after login to the redirect in the “passwordless_login.php file.

    
    /**
     * Automatically logs in a user with the correct nonce
     *
     * @since v.1.0
     *
     * @return string
     */
    add_action( 'init', 'wpa_autologin_via_url' );
    function wpa_autologin_via_url(){
    	if( isset( $_GET['token'] ) && isset( $_GET['uid'] ) && isset( $_GET['nonce'] ) ){
    		$uid = sanitize_key( $_GET['uid'] );
    		$token  =  sanitize_key( $_REQUEST['token'] );
    		$nonce  = sanitize_key( $_REQUEST['nonce'] );
    
    		$hash_meta = get_user_meta( $uid, 'wpa_' . $uid, true);
    		$hash_meta_expiration = get_user_meta( $uid, 'wpa_' . $uid . '_expiration', true);
    		$arr_params = array( 'uid', 'token', 'nonce' );
    		$current_page_url = remove_query_arg( $arr_params, wpa_curpageurl() );
    
    		require_once( ABSPATH . 'wp-includes/class-phpass.php');
    		$wp_hasher = new PasswordHash(8, TRUE);
    		$time = time();
    
    		if ( ! $wp_hasher->CheckPassword($token . $hash_meta_expiration, $hash_meta) || $hash_meta_expiration < $time || ! wp_verify_nonce( $nonce, 'wpa_passwordless_login_request' ) ){
    			
    			wp_redirect( $current_page_url . '?wpa_error_token=true' );
    			exit;
    		} else {
    			wp_set_auth_cookie( $uid );
    			delete_user_meta($uid, 'wpa_' . $uid );
    			delete_user_meta($uid, 'wpa_' . $uid . '_expiration');
    
    			$total_logins = get_option( 'wpa_total_logins', 0);
    			update_option( 'wpa_total_logins', $total_logins + 1);
    			//Old redirect
    			//wp_redirect( $current_page_url );
                            //Custom redirect
    			wp_redirect( 'http://YOUR-LANDING-PAGE.COM' );
    			exit;
    		}
    	}
    }
    

    A better way would be to write a small plugin overwriting the existing redirect, so you don´t get in trouble when updating the Plugin.

    Best,
    Marc

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘URL after Login’ is closed to new replies.