Using Gravity Forms ‘gform_web_api_capability_delete_entries’ PHP action

The gform_web_api_capability_delete_entries filter in Gravity Forms allows you to change the capability required for a user to delete entries via the web API.

Usage

add_filter('gform_web_api_capability_delete_entries', function ($capability) {
    // your custom code here
    return $new_capability;
});

Parameters

  • $capability (string) – The capability required. Defaults to ‘gravityforms_delete_entries’.

More information

See Gravity Forms Docs: gform_web_api_capability_delete_entries

Examples

Change the capability required to delete entries

Change the capability required for a user to delete entries via the web API to ‘delete_others_posts’:

add_filter('gform_web_api_capability_delete_entries', function ($capability) {
    return 'delete_others_posts';
});

Allow administrators to delete entries

Allow only administrators to delete entries via the web API:

add_filter('gform_web_api_capability_delete_entries', function ($capability) {
    return 'manage_options';
});

Create a custom capability for deleting entries

Create a custom capability ‘custom_delete_entries_capability’ for users to delete entries via the web API:

add_filter('gform_web_api_capability_delete_entries', function ($capability) {
    return 'custom_delete_entries_capability';
});

Allow editors to delete entries

Allow editors to delete entries via the web API:

add_filter('gform_web_api_capability_delete_entries', function ($capability) {
    return 'delete_published_posts';
});

Restrict entry deletion to a specific user role

Allow only users with a custom role ‘entry_deleter’ to delete entries via the web API:

add_filter('gform_web_api_capability_delete_entries', function ($capability) {
    if (current_user_can('entry_deleter')) {
        return 'gravityforms_delete_entries';
    }
    return 'do_not_allow';
});