-1

I am looking for a way to restrict users of a certain role to only be able to access one page on my wordpress site. When a user of the role logs in they should be redirected to the page and they should not be able to access any other pages. I have tried multiple plugins that can restrict pages to users, but I have not found one that can restrict users to pages. Does this functionality exist within Wordpress and how would I implement it if it does?

closed as too broad by bosco, Jacob Peattie, cjbj, rudtek, Mayeenul Islam May 21 at 7:52

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

You'd have to add a function during the init action of WP. There you'll get the current user and check whether they have a specific role assigned to them and redirect to the page when they do.

add_action('init', function () {
    $user = wp_get_current_user();
    $role = 'your role';

    if (in_array($role, $user->roles)) {
        wp_redirect('url');
    }
});

WordPress Function References:

Relevant SE posts:

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