0

I have created a custom login form that will use the default action of the wordpress one. I need to display errors on it if occurs but at the moment the user will be redirected to wp-login.php in case of errors. Also I want that users are redirected to specific page based on their role, I have two custom roles and I need to show different pages to each single role.

How I can accomplish this, will the login_redirect filter be useful if I add it in a custom plugin?

Will a custom page added to dashboard using add_menu_pagecan be displayed to user without a particular role, or there is another way to replace the default dashboard?

1 Answer 1

0

For redirect you can do something like this.

function redirect_to_page() {
    global $user;

    if (in_array( 'specified_role', $user->roles ) ) {
        return '/wp-admin/post.php?post=7&action=edit';
    }
}

add_filter('login_redirect', 'redirect_to_page');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.