Title: WordPress Redirect Function Edition
Last modified: August 24, 2016

---

# WordPress Redirect Function Edition

 *  [carbonie](https://wordpress.org/support/users/carbonie/)
 * (@carbonie)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/wordpress-redirect-function-edition/)
 * 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.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [carbonie](https://wordpress.org/support/users/carbonie/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/wordpress-redirect-function-edition/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
