No, already checked, not useful
And too easy with a plugin like that one! (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'] = '
<tr>
<th><label for="my_custom_setting">My role</label></th>
<td><input value="' . rgar($form, $user_role) . $user_role .'" name="my_custom_setting" readonly>
'.$my_meta_value.'
</td>
</tr>';
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;
}