I want to create a user role-based redirect using the bricks/auth/custom_login_redirect filter, but the documentation and the example provided in the following link are not clear enough for me: Bricks Builder Documentation.
I wrote the following code with the help of ChatGPT, which worked for redirection based on user roles, but it broke the login page:
I adopted your code but it is still not working, the login is successful but stays on the login page without any redirect.
would you mind telling me what I am missing here?
thanks
function role_based_redirection() {
$user = wp_get_current_user();
$redirect_url = 'https://mywebsite; //default
if ( in_array( āadministratorā, $user->roles ) || in_array( ābusiness-editorā, $user->roles ) ) {
$redirect_url = āhttps:/mywebsite.com/ā;
} elseif ( in_array( āeditorā, $user->roles ) ) {
$redirect_url = āmywebsite.com is available for purchase - Sedo.comā;
}
Thanks a lot for coming back but unfortunately, itās still not working, it does not matter who is logging in (admin or Editor) always goes to the default URL (Home Page).
Here is the Code I used:
Please send your admin credentials to help@bricksbuilder.io and include this forum thread as a reference.
Let me know the page URL you are working on so I can directly check your issue.
I was trying this on a local host before I implemented it on my live site, but Iāll try to duplicate it on the live site now and if it does not work Iāll create an admin account may be Bricks can help.
But in the meantime and if you do not mind me asking:
How can I use a plugin like āLoginWP (Formerly Peterās Login Redirect)ā with Bricks Custom Login Page instead of the Snippet Code? It has no function to add it to the Bricks form.
I am sorry that I never used that plugin before.
I just checked the plugin description, seems like you donāt need to use Bricks custom authentication pages if you are using that plugin.