Skip to:
Content
Pages
Categories
Search
Top
Bottom

Enable “Create a Group” button for Admin and Editor role only

  • @giorrous

    Participant

    Hello,

    I want to hide “Create a Group” button for all user roles except Admin and Editor.I want to make it so that only Admins and Editors are allowed to create groups.
    Any ideas how can i achive this?

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • @henrywright

    Moderator

    You could use current_user_can() to check the member’s capabilities. For example:

    if ( current_user_can( 'edit_pages' ) ) {
        // Output button
    }

    Ref: https://codex.wordpress.org/Roles_and_Capabilities

    @giorrous

    Participant

    Thanks for the answer!!
    In which file i must write this code?

    @henrywright

    Moderator

    It isn’t a copy-and-paste thing. You’d need to place your button inside the condition.

    @giorrous

    Participant

    Ok thanks i’ll try it

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Enable “Create a Group” button for Admin and Editor role only’ is closed to new replies.
Skip to toolbar