gravityflow_editable_fields_user_input

The gravityflow_editable_fields_user_input filter allows the list of editable fields for a user input step to be filtered.

Example 1: Modify the editable fields

add_filter( 'gravityflow_editable_fields_user_input', 'sh_gravityflow_user_input_fields', 10, 2 );
function sh_gravityflow_user_input_fields( $editable_fields, $step ) {
	//Modify with the field IDs you want to be allowed to edit
	$editable_fields = array('2', '3', '7');
  	return $editable_fields;  
}

Example 2: Modify the editable fields based on Step ID / user role

add_filter( 'gravityflow_editable_fields_user_input', 'sh_gravityflow_user_input_fields', 10, 2 );
function sh_gravityflow_user_input_fields( $editable_fields, $step ) {

    if ( $step && $step->get_id() == 91 ) {
        $user = wp_get_current_user();
        if ( in_array( 'administrator', (array) $user->roles ) ) {
		//Modify with the field IDs you want to be allowed to edit
		$editable_fields = array( '2', '3' );
        }
    }
    return $editable_fields;
}

Example 3: Modify the editable fields based on form ID

add_filter( 'gravityflow_editable_fields_user_input', 'sh_gravityflow_user_input_fields', 10, 2 );
function sh_gravityflow_user_input_fields( $editable_fields, $step ) {

    if ( $step ) {
        $entry = $step->get_entry();
        //Modify with the array of form IDs you want to customize the editable fields for.
        if( $entry && in_array( $entry['form_id'], array( '1', '3,', '17' ) ) ) {
		//Modify with the field IDs you want to be allowed to edit
        	$editable_fields = array( '2', '3' );
        }
    }
    return $editable_fields;
}

Example 4: Remove any editable fields that have the Gravity Perks Read Only setting active.

add_filter( 'gravityflow_editable_fields_user_input', 'gflow_gperks_read_only_user_input', 10, 2 );
function gflow_gperks_read_only_user_input( $editable_fields, $step ) {
	$form = GFAPI::get_form( $step->get_form_id() );
	$remove_read_only_ids = array();
	//Loop through the form fields to identify ones which are both selected as editable and have the perk setting active
	foreach ( $form['fields'] as $field ) {
		if ( in_array( $field['id'], $editable_fields ) && rgar( $field, 'gwreadonly_enable' ) ) {
			$remove_read_only_ids[] = $field['id'];
		}
	}
	//Remove any that had overlapping settings. Result is that display fields setting in step will apply to the "removed" fields.
	if ( ! empty( $remove_read_only_ids ) ) {
		$editable_fields = array_diff( $editable_fields, $remove_read_only_ids );
	}

	return $editable_fields;
}

Placement

This code should be placed in the functions.php file of your active theme