In order to redirect a user to the home page after login in WordPress, you will first need to create a function in your WordPress theme or plugin to handle the redirect. Once you have created the function, you will need to include the following code in it:
function redirect_after_login() { global $user; if ($user->user_login == ‘admin’) { return home_url(); } elseif($user->user_login == ‘user’) { return user_login_url($user->user_id); } else { return site_url(); } }
To use the function, you will need to include it in the wp_login_form() function in your theme or plugin. The wp_login_form() function will be called after the user has entered their login credentials. In the function, you will need to check to see if the user is logged in as admin or user.
If the user is logged in as user, you will return the user_login_url() function, which will return the user’s login page. If the user is logged in as admin, you will instead return the home_url() function, which will return the home page of your website.
4 Related Question Answers Found
If you’re logging in to your WordPress site, and you want to go to another page, you need to use the “redirect” function. To do this, you first need to find the URL for the page you want to go to. You can do this by clicking on the “Home” link on the main toolbar, or by typing the URL into the address bar on your browser.
If you want to redirect a WordPress login page after logging out, the easiest way to do so is to add a line of code to your login.php file. To do this, open login.php in your WordPress installation and find the following line of code:. require_once(‘./wp-config.
If you have an old page that you want to redirect people to, you can use the 301 redirect feature in WordPress. To do this, first go to your WordPress site’s dashboard, and under “Posts” click on the “Post” you want to redirect. You’ll see the “Edit” link next to the “Title” field.
If you are using a WordPress site and have logged in, your browser may have automatically redirected you to a different URL. If you are using a public site, this URL may be displayed in your browser address bar. If you are using a private site, the URL may be hidden from view.