As for such a code

/** * Wrap the default action HTML for .o2-resolve-link actions */ function wrap_post_action_html( $html, $action ) { if ( self::post_actions_key === $action[ 'action' ] && ! empty( $html ) ) { $html = "<span class='o2-resolve-wrap'>{$html}<ul></ul></span>"; } return $html; } 

You can prescribe a condition so that only the admin and authors of the post can see the button (but the main admin, because he is the only author)?

    2 answers 2

    current_user_can () - Checks the rights of the current user to perform the specified action.

     /** * Wrap the default action HTML for .o2-resolve-link actions */ function wrap_post_action_html( $html, $action ) { if(current_user_can('administrator')){ if ( self::post_actions_key === $action[ 'action' ] && ! empty( $html ) ) { $html = "<span class='o2-resolve-wrap'>{$html}<ul></ul></span>"; } return $html; } } 
    • that's how it works. but there is generally no hint of is_admin () - user278690
    • @Chernikova again, is_admin () - Checks if the user is in the admin panel of the site (console or any other admin page). You need "current_user_can" - Daniel
    • yes, it does not depend on the admin panel or not. The post and the label are in the blog posts. - user278690

    It is necessary to check the capabilities of the role, but in no case its name.

    Correct: if(current_user_can('manage_options')) .

    Incorrect: if(current_user_can('administrator')) .

    • so it worked too - user278690