WordPress.org

Ready to get started?Download WordPress

Forums

.htaccess redirect based on user role (2 posts)

  1. Mode7James
    Member
    Posted 2 years ago #

    I'm trying to redirect certain users without the correct role to the login page. Currently I've gotten it to work with basic "wordpress_logged_in" from the cookie:

    RewriteCond %{REQUEST_URI} ^.*staging/.*
    RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
    RewriteRule . /wp-login.php?redirect_to=%{REQUEST_URI} [R,L]

    I would like to find the current user's role, so I can filter based on this role. Is this possible? Thanks!

  2. markparolisi
    Member
    Posted 2 years ago #

    write a function that runs on an action like 'template_redirect' to find the user role and then use the following function to handle the redirect.
    http://codex.wordpress.org/Function_Reference/wp_redirect

Topic Closed

This topic has been closed to new replies.

About this Topic