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]