Monday, July 25, 2022
HomeWordPress Developmentcapabilities - Stop all customers from modifying posts besides admins utilizing hooks

capabilities – Stop all customers from modifying posts besides admins utilizing hooks


So I am trying to dam out all put up edits for all customers besides admins, so I’ve the next setup:

add_filter('post_row_actions', [self::class, 'remove_edit_permissions'], 10, 2);

public static operate remove_edit_permissions(array $actions = []): array
{
    $consumer = Person::init();
    if (is_null($consumer)) {
        return [];
    }
    if (!$user->function()->has_capability('manage_options')) {
        if (isset($actions['inline hide-if-no-js'])) {
            unset($actions['inline hide-if-no-js']);
        }
        if (isset($actions['edit'])) {
            unset($actions['edit']);
        }
    }

    return $actions;
}

This works nice, it blocks out the “Fast Edit” and “Edit” buttons within the Admin Submit UI comparable to beneath:

enter image description here

Downside:

Customers are nonetheless in a position to entry the edit url and make adjustments comparable to this: https://instance.com/wp-admin/put up.php?put up=10690&motion=edit

Is there a technique to limit hyperlink modifying additionally?

Is there a a lot better options on modifying prevention utilizing some form of hook or filter?

All assist shall be appreciated!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments