Contents
Change the field type before it is displayed in your form.
Parameters: $field type (string), $field (object)
Examples
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($field->id == 25){ //change 25 to the id of the field to change
if(!is_admin() and !current_user_can('editor')) //if current user is not an editor
$type = 'hidden'; //hide this field
}
return $type;
}
Hide fields from logged in users
add_filter('frm_field_type', 'change_my_field_type', 10, 2);
function change_my_field_type($type, $field){
if(in_array($field->id, array( 101,88,94))){ //the ids of fields to hide
if(!is_admin() and is_user_logged_in()) //if current user is logged in
$type = 'hidden'; //hide this field
}
return $type;
}
Hide a field when editing
add_filter('frm_field_type', 'change_my_field_type', 10, 2);
function change_my_field_type($type, $field){
if($field->id == 25){ //change 25 to the id of the field to change
global $frm_editing_entry;
if(!is_admin() and $frm_editing_entry) //if not in admin area and editing an entry
$type = 'hidden'; //hide this field
}
return $type;
}