block editor – Remove ability to edit posts for all users except admins

Question

So I have been wanting to figure this out for some time now and I can’t seem to work it out, but I would like to have a complete post edit restriction for posts.

So I have the following code:

public function remove_edit_permissions($actions = [])
{
    if (isset($actions['inline hide-if-no-js'])) {
        unset($actions['inline hide-if-no-js']);
    }
    if (isset($actions['edit'])) {
        unset($actions['edit']);
    }

    return $actions;
}
add_filter('post_row_actions', [$this, 'remove_edit_permissions'], 10, 2 );

Which removed the “Edit” and “Quick Edit” buttons in the admin UI:
enter image description here

Does anyone know how I can also restrict access to edit using the hyperlink?

Example: https://example.com/wp-admin/post.php?post=9851&action=edit

All help will be appreciated!

0
theMap 3 weeks 2022-07-17T20:53:40-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse