Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
add_filter('frm_field_type', 'hide_admin_only_fields_on_front_end', 10, 2);
function hide_admin_only_fields_on_front_end($type, $field) {
global $wpdb;
$frm_fields = $wpdb->prefix . 'frm_fields';
$regexp = '"admin_only";s:13:"administrator"';
$field_ids = $wpdb->get_results("SELECT id FROM $frm_fields where field_options REGEXP '" . $regexp . "'", ARRAY_A);
$admin_field_ids = array();
foreach( $field_ids AS $row ) {
$admin_field_ids[] = $row['id'];
}
if(in_array($field->id, $admin_field_ids )) {
if( (!is_admin() || defined('DOING_AJAX') ) ) {
$type = 'hidden';
}
}
return $type;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment