Using Gravity Forms ‘gform_web_api_capability_put_entries’ PHP filter

The gform_web_api_capability_put_entries filter allows you to modify the capability required for updating entries via the Gravity Forms web API.

Usage

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

Parameters

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

More information

See Gravity Forms Docs: gform_web_api_capability_put_entries

Examples

Change capability to ‘manage_options’

Allow users with the ‘manage_options’ capability to update entries via the web API.

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

Grant capability based on user role

Allow users with the ‘editor’ role to update entries via the web API.

add_filter('gform_web_api_capability_put_entries', 'allow_editor_role');
function allow_editor_role($capability) {
    if (current_user_can('editor')) {
        return 'gravityforms_edit_entries';
    }
    return $capability;
}

Grant capability based on user ID

Allow a specific user with user ID 5 to update entries via the web API.

add_filter('gform_web_api_capability_put_entries', 'allow_specific_user');
function allow_specific_user($capability) {
    $user = wp_get_current_user();
    if ($user->ID == 5) {
        return 'gravityforms_edit_entries';
    }
    return $capability;
}

Grant capability based on custom user meta

Allow users with a custom user meta ‘can_update_entries’ set to ‘yes’ to update entries via the web API.

add_filter('gform_web_api_capability_put_entries', 'allow_custom_user_meta');
function allow_custom_user_meta($capability) {
    $user = wp_get_current_user();
    if (get_user_meta($user->ID, 'can_update_entries', true) == 'yes') {
        return 'gravityforms_edit_entries';
    }
    return $capability;
}

Completely disable updating entries via the web API

Disable the ability to update entries via the web API for all users.

add_filter('gform_web_api_capability_put_entries', 'disable_update_entries');
function disable_update_entries($capability) {
    return 'do_not_allow';
}