How to Redirect Users after Successful Login in WordPress
Check Out More At: WP Beginner
WordPress: Best WordPress Plugins | WordPress Tutorials
How to Redirect Users after Successful Login in WordPress
Product Image | Product Name / Primary Rating / Price | Primary Button / Description |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Elementor is an amazing website builder plugin for WordPress. Elementor makes it easy to create beautiful and high converting websites yourself without having to learn code.
Gravity Forms is a WordPress plugin that creates powerful forms quickly and easily, with drag-and-drop fields, custom notifications and confirmations, and custom styling capability.
Kadence Theme is a powerful, intuitive and flexible WordPress theme that offers an expansive set of features and customization options.
It includes a robust page builder, beautiful design options, mobile-friendly responsiveness, powerful SEO tools and optimized performance for faster loading times.
It's perfect for creating stunning websites without needing to write any code.
Cloudways is a managed cloud hosting platform that simplifies cloud infrastructure deployment and management.
It provides an intuitive dashboard, automated backups and optimized stack for speedy performance. It also provides 24x7 support with multiple server locations, enabling businesses to host their applications quickly and securely.
After a successful login in WordPress, you may want to redirect your users to a specific URL. This can be done by using a simple plugin or adding a code snippet to your functions.php file.
In this article, we will show you how to redirect users after successful login in WordPress.
Method 1: Redirect Users After Successful Login in WordPress Using a Plugin
First thing you need to do is install and activate the Peter’s Login Redirect plugin. Upon activation, you need to visit Settings » Login Redirect page to configure the plugin settings.
The plugin allows you to redirect users to specific pages based on user roles. You can also set a default redirect URL for all users.
Method 2: Redirect Users After Successful Login in WordPress Without a Plugin
If you don’t like plugins or if you are already using a plugin that allows you to customize the WordPress login page, then you can add a code snippet to your child theme’s functions.php file or site-specific plugin.
function wpb_s_login_redirect() {
global $current_user;
get_currentuserinfo();
if (is_user_logged_in()) {
if (current_user_can(‘administrator’)) {
echo “Howdy “. $current_user->user_login .”, \n\n”;
} else {
echo “Howdy guest, \n\n”;
}
} else {
echo “You are not logged in”;
}
}