Redirecting users to different landing pages

[ad_1]

I’m making a website with the help of Breakdance, and I’m trying to make a Login page where the login-button would redirect different users to different pages. I managed to make it partly work through wp-login.php page with the help of a code snippet I made with chat.openai, but it doesnt work through the Breakdance login form button. On the form, there’s one box where I can assign the redirecting page, but that doesnt help me because I dont want all the users to be redirected to the same page. I’ve also tried to make it work with different plugins, but they only work through wp-login.php. I would like the login-action to happen through my custom login page I made using the breakdance login form.

Since I’m not a coder and really quite a noob with these things, do you guys know how to solve this problem?

If this is useful information, I’ll add the code snippet that works through wp-login.php

/*
Plugin Name: Custom Login Redirect Based on Username
Description: Redirect users to different pages after login based on their usernames.
*/

function custom_login_redirect_by_username( $redirect_to, $request, $user ) {
// Check if the user is logged in
if ( isset( $user->user_login ) ) {
// Redirect based on username
switch ( $user->user_login ) {
case ‘User1’:
// Redirect User1 to the specified link
return ‘https://www.portal.coresbond.com/user1’;
case ‘User2’:
// Redirect User2 to the specified link
return ‘https://www.portal.coresbond.com/User2’;
case ‘User3’:
// Redirect User3 to the specified link
return ‘https://www.portal.coresbond.com/user3’;
default:
// Redirect other users to the default page
return home_url();
}
} else {
return $redirect_to;
}
}
add_filter( ‘login_redirect’, ‘custom_login_redirect_by_username’, 10, 3 );

​

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer