Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfontjr/26edc40a382cfebd546a7dbb674636f5 to your computer and use it in GitHub Desktop.
Save vfontjr/26edc40a382cfebd546a7dbb674636f5 to your computer and use it in GitHub Desktop.
<?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