0

I have a site with a bunch of custom post types, and a few plugins. I would like it so that editors ONLY have access to see posts when they visit a site.

Does anyone know of how I can do that? I understand I can add capability functions to the custom post types, but I want to be able to just hid everything BUT posts when they log in.

Any guidance would be greatly appreciated.

Thanks Mike

1 Answer 1

1

If u do not want to hack a lot into function.php of your wordpress, I would like to suggest you use:

Admin Menu Editor PLUGIN, Lets you directly edit the WordPress admin menu. You can re-order, hide or rename existing menus, add custom menus and more.

which works great for me.

But anyway if u want to hack using if-else to display diffent contents can use below code

// can reuse this custom function
function get_current_user_role() {
global $wp_roles;
$current_user = wp_get_current_user();
$roles = $current_user->roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false;
}

then

if(is_user_logged_in()) {
$currentrole =  get_current_user_role();
if( $currentrole == "Editors"){    // could be any role even custom roles.
   // see what kind of contents;
}else{
   // see other kinds of contents;
}

I've been using this kind of code in one of my project, it's working well, so if maybe can help u.

2
  • Thanks for the reply, I think the plugin would do the trick... either way I'd have to set specifically what the users are to see so the plugin works, even though I would avoid like to use a plugin it seems to what I need pretty well. Commented Nov 6, 2014 at 16:25
  • feeling very glad when i receive your comment. Thank you for your comment too. @Mixmastermiike
    – BOBO
    Commented Nov 6, 2014 at 16:31

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.