Home>

I want to hide items on the wordpress article list page, quick edits, except for administrators.

Error message

I tried the following code, but the quick edit is hidden even in the case of an administrator.

Applicable source code
function custom_post_row_actions ($actions, $post) {
 if ($post->post_status == "publish" || $post->post_status == "future")
 unset ($actions ['inline hide-if-no-js']);
 return $actions;
 }
 add_filter ("post_row_actions", "custom_post_row_actions", 0, 2);
if (! is_super_admin ()) {
add_action ('do_custom_post_row_actions', 'custom_post_row_actions');
}
Supplemental information (FW/tool version etc.)

Since the quick edit itself is hidden, I think the first half is not wrong
if (! is_super_admin ()) { Can't solve it anyway ...

Thanks for your consideration.

  • Answer # 1

    Maybe if you write.

    function custom_post_row_actions ($actions, $post) {
        if (! is_super_admin ()&&($post->post_status == "publish" || $post->post_status == "future")) unset ($actions ['inline hide-if-no- js']);
        return $actions;
    }
    add_filter ("post_row_actions", "custom_post_row_actions", 0, 2);

    [is_super_admin – WordPress private manual]

Related articles