WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Anbody using "if ( current_user_can( 'editor' )) {"??? (9 posts)

  1. speedyp
    Member
    Posted 1 year ago #

    I found a bit of code that is supposed to hide various dashboard menu items from users, depending on their role.

    I've tried adding this to my multisite, but it doesn't seem to recognise the "editor" role?

    function delete_menu_items(){
    		remove_menu_page('tools.php'); // Tools
    		remove_menu_page('options-general.php'); // Settings}
    	if ( current_user_can( 'editor' ))
    {add_action( 'admin_init', 'delete_menu_items' );}

    If I swap editor for administrator then it removes the items from the admin menu and leaves them if you're an editor.. just can't seem to get it to work the other way round, which is what I need?

    Thanks

  2. Where/when are you adding it?

  3. speedyp
    Member
    Posted 1 year ago #

    I'm adding it to the functions page of my new template theme functions.php
    (near the top if that makes any difference?)

    The default role for subsites will be editor, but there's a few things I want to hide to keep things as simple as possible for them.

    I am already using the role editor, but it only goes so far...

    Cheers

  4. editor isn't a valid value for current_user_can ;)

    http://codex.wordpress.org/Roles_and_Capabilities

    I'd do this: if ( !current_user_can( 'activate_plugins' ))

  5. speedyp
    Member
    Posted 1 year ago #

    Thanks Mika - I'll give it a shot.
    You're working overtime tonight - hope you're well paid :)

  6. Paid... For ... WordPress? :D (I'm a volunteer, and actually killing time before I get on a plane and go home from Vacation!)

  7. speedyp
    Member
    Posted 1 year ago #

    YAY - give yourself a raise - that suggestion worked perfectly.
    THANK YOU :)

  8. speedyp
    Member
    Posted 1 year ago #

    LOL - well you're doing a fantastic job. Feel free to kill as much time as you want on my dumb problems...

  9. BookClubReader
    Member
    Posted 10 months ago #

    Thanks, this helped greatly!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.