Order options by entry ID

add_filter(‘frm_data_sort’, ‘frm_my_data_sort’, 21, 2); function frm_my_data_sort( $options, $atts ) { if ( $atts[‘dynamic_field’][‘id’] == 100 ) { //change 100 to the ID of the Dynamic field ksort( $options );//sorts options by entry ID } return $options; }Continue reading

Remove duplicates from Dynamic field

add_filter(‘frm_data_sort’, ‘frm_remove_duplicates’, 21, 2); function frm_remove_duplicates( $options, $atts ) { if ( $atts[‘dynamic_field’][‘id’] == 100) { //change 100 to the ID of the Dynamic field $options = array_unique( $options ); } return $options; }Continue reading

Make field read-only for non-administrators

add_filter(‘frm_setup_new_fields_vars’, ‘frm_set_read_only_on_create’, 9, 2); add_filter(‘frm_setup_edit_fields_vars’, ‘frm_set_read_only_on_create’, 9, 2); function frm_set_read_only_on_create( $values, $field ){ // If on the back-end, keep fields editable if ( FrmAppHelper::is_admin() || current_user_can( ‘administrator’ ) ) { return $values; } // If on front-end, make specific fields…Continue reading

Set fields to read-only when editing

add_filter(‘frm_setup_edit_fields_vars’, ‘frm_set_read_only’, 20, 3); function frm_set_read_only($values, $field, $entry_id){ // If on the back-end, keep fields editable if ( FrmAppHelper::is_admin() ) { return $values; } // If on front-end, make specific fields read-only if ( in_array( $field->id, array( 1558,554,555,556 ) )…Continue reading

Set field value when editing

add_filter(‘frm_setup_edit_fields_vars’, ‘frm_set_edit_val’, 20, 3); function frm_set_edit_val( $values, $field, $entry_id ) { if ( $field->id == 171 ) { //Replace 171 with your field ID // If on the back-end, don’t adjust field value if ( FrmAppHelper::is_admin() ) { return $values;…Continue reading

Set the default value of a field

add_filter(‘frm_get_default_value’, ‘my_custom_default_value’, 10, 3); function my_custom_default_value( $new_value, $field, $is_default ) { if ( $field->id == 25 && $is_default ) { //change 25 to the ID of the field $new_value = ‘default’; //change ‘default’ to your default value } return $new_value;…Continue reading

Conditionally switch default value

add_filter(‘frm_get_default_value’, ‘switch_my_default_value’, 10, 2); function switch_my_default_value( $new_value, $field ){ if ( in_array( $field->id, array( 25, 26, 27 ) ) ) { if ( isset( $_GET[‘pass_entry’] ) ) { $new_value = do_shortcode( ‘[frm-field-value field_id=’ . $field->id . ‘ entry=pass_entry]’ ); }…Continue reading

Populate a field with the original referring url

add_filter(‘frm_get_default_value’, ‘my_custom_default_value’, 10, 2); function my_custom_default_value($new_value, $field){ if($field->id == 25){ //change 25 to the ID of the field $new_value = reset($_SESSION[‘frm_http_referer’]); //stores the value of the referring URL } return $new_value; }Continue reading

Select current user’s option in Dynamic field

add_filter(‘frm_get_default_value’, ‘auto_populate_dynamic_field’, 10, 2); function auto_populate_dynamic_field($new_value, $field){ if ( $field->id == 25 ) { //change 25 to the ID of the Dynamic field global $wpdb; $user = wp_get_current_user(); $entry_id = $wpdb->get_var( $wpdb->prepare( “SELECT id FROM ” . $wpdb->prefix . “frm_items…Continue reading

Hide a field from non-editors

add_filter(‘frm_field_type’, ‘change_my_field_type’, 10, 2); function change_my_field_type($type, $field){ if(in_array($field->id, array(125,126,127))){ //change 125, 126, and 127 to the ids of fields to hide if(!is_admin() and !current_user_can(‘editor’))//if current user is not an editor $type = ‘hidden’; //hide the fields } return $type; }Continue reading