Answers for "wordpress account creation referrer page"

PHP
0

wordpress account creation referrer page

function redirect_user_tologin(){
  global $post;
  $post_slug = $post->post_name;

  if(!is_user_logged_in()){
      if($post_slug == 'my-account') { //can add multiple conditions

          //create dynamic redirect page link
          $redirect = urlencode(site_url().'/'.$post_slug);

          //redirection
          wp_safe_redirect(site_url().'/wp-login.php/?redirect_to=' .$redirect);
          exit;
       }
   }
}
add_action('wp', 'redirect_to_login');
Posted by: Guest on January-13-2021

Code answers related to "wordpress account creation referrer page"

Browse Popular Code Answers by Language