Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am having private page.I want to show this page only when "subscriber" logged in."Editor" should not access this page.How can i set the privilege.

share|improve this question

1 Answer

up vote 1 down vote accepted

Without a plugin something like this should work

    //functions.php
    function get_user_role() {
    global $current_user;

    $user_roles = $current_user->roles;
    $user_role = array_shift($user_roles);

    return $user_role;
    }

    //page template
    $role = get_user_role();
    if($role == "subscriber"){
       //cool you can see this
    }
    else {
       //sorry not allowed
    }

A BETTER way would be to use something like the Members Plugins which lets you have custom roles and check roles and such.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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