• There is two snippet first one is working

    function auto_login_new_user( $user_id ) {
    	wp_set_current_user($user_id);
    	wp_set_auth_cookie($user_id);
    	wp_redirect( home_url('/account') );
    }
    add_action( 'user_register', 'auto_login_new_user' );
    
    function possibly_redirect_register(){
    		$notice_url = site_url('/account-notice');
    		$register = $_GET['register'];
    			if ($register == false) {
    				wp_redirect($notice_url . '?secure=errorRegister' );
    			}
    }
    add_action('init','possibly_redirect_register');
    
    function possibly_redirect_reset(){
    		$notice_url = site_url('/account-notice');
    		$reset = $_GET['reset'];
    			if ($reset == false) {
    				wp_redirect($notice_url . '?secure=errorReset' );
    			}
    			else {
    				wp_redirect($notice_url . '?secure=successReset' );
    			}
    }
    add_action('init','possibly_redirect_register');

    their senses are same and this one not working

    function possibly_redirect_register( $user_id ){
    		$notice_url = site_url('/account-notice');
    		$register = $_GET['register'];
    			if ($register == true) {
    				wp_set_current_user($user_id);
    				wp_set_auth_cookie($user_id);
    				wp_redirect( home_url('/account') );
    				//wp_redirect($notice_url . '?secure=successRegister' );
    			}
    			else {
    				wp_redirect($notice_url . '?secure=errorRegister' );
    			}
    		$reset = $_GET['reset'];
    			if ($reset == true) {
    				wp_redirect($notice_url . '?secure=successReset' );
    			}
    			else {
    				wp_redirect($notice_url . '?secure=errorReset' );
    			}
    }
    add_action('init','possibly_redirect_register');
    add_action('user_register','possibly_redirect_register');

    i don’t understand whats wrong. Thanks for help.

The topic ‘WordPress Redirect Function Edition’ is closed to new replies.