Form list backend restrictions

Hi there, I would like to know if it’s possible to show the list of forms based on role.

I create two kind of custom roles with GF capabilites to see and edit forms (using User role editor plugin):

  • Content manager role
  • HR manager role

Each of them should see only the forms created in backend by the users with the same role, not the forms created by users with the other role.

What I don’t know is which element of the form I can get to do the control: if I could get the single form author ID/name/email, I could create a control function, but I can’t find infos about getting that data from a single form.


I think this plugin accomplishes what you are looking to do?

No, already checked, not useful :wink:
And too easy with a plugin like that one! :smiley: (Joking)

BTW In the meantime I’m going forward by checking GF API:

I’m getting the current user role(s) and store as meta value of the single form, in this way I know what kind of user created the form (added a backend print of the value to debug).
Then I would like to retrieve the meta value and use it to query the list of forms based on that meta value.

So far i went through that:

add_filter( 'gform_form_settings', 'my_custom_form_setting', 10, 2 );
function my_custom_form_setting( $settings, $form ) {
        //Trying to see if I can get back the previously stored display_meta (serialized) value  	
	$entry_id = $form['id'];
	$my_meta_value = gform_get_meta( $entry_id, 'my_custom_setting' );

        // Get the current backend user role(s) 
	$user = wp_get_current_user();
	$roles = ( array ) $user->roles;
        //This needs to be refined of course, i'm getting just the first value for testing purpose
	$user_role = $roles[0];
        //Printing the readonly text input field with the role value (it works, already tested, I'll hide when finished or leave the view of the value only to specific user, ) but I try to print also the meta value previously stored via $my_meta_value, but unsuccessfully 
        $settings[ __( 'Author (Not editable)', 'gravityforms' ) ]['my_custom_setting'] = '
            <th><label for="my_custom_setting">My role</label></th>
            <td><input value="' . rgar($form, $user_role) . $user_role .'" name="my_custom_setting" readonly>
    return $settings;

//Store the retrieved user role to the display_meta serialized form record
add_filter( 'gform_pre_form_settings_save', 'save_my_custom_form_setting' );
function save_my_custom_form_setting($form) {
    $form['my_custom_setting'] = rgpost( 'my_custom_setting' );
    return $form;

The final goal would be to use the “gform_form_list_forms” filter in order to get only the forms with that meta_display value stored during the form creation, associated to the current user role. Due to a match logic to quickly say.

Like the example (or perhaps I need to do something before the list, like work on the query):

add_filter( 'gform_form_list_forms', 'filter_forms', 10, 6 );
function filter_forms( $forms, $search_query, $active, $sort_column, $sort_direction, $trash ){
    $forms = "let's find what to do here!";
    return $forms;

@Davide hi there, did you manage to solve your problem?
I need less or more the same feature.

Thank you!

Hi Marco. Did you already evaluate this plugin to see if it will work in your scenario?

Of course, it’s not useful.
I need to show only some forms from the forms list, to specific users.
With that plugin it’s not possible.

Hey @Riccardo,

With Advanced Permissions, if a user does not have access to any feature of a form, that form will not appear on the form list.

This can be achieved by setting up a new rule for that specific user/role and disabling all the available capabilities.

1 Like