0

I have two plugins that I want only Editors or Admins to be able to use (they push-publish to FB and Twitter and I don't want any user to be able to do that). So, I'm looking for how to edit each plugin to add permission restrictions. Both plugins create options boxes within the Page or Post editor, and basically I'd like these to appear only to those with proper role status.

I'm thinking something like:

if ( current_user_can( 'manage_categories' ) add_action( ... );

... but am simply not good enough with code to write what I'd like. Can anyone help out?

Jon Fergus
  • 171
  • 1
  • 9

1 Answers1

0

You would want to grab the users role since user_can describes capabilities that may belong to more than one role.

$roles= $current_user->roles;
$role = array_shift($roles);

Will give you a plain English string to compare. Then you can do

if ($role == "administrator" || $role == "editor") add_action ...  
Jon Lachonis
  • 911
  • 1
  • 8
  • 18