Created
April 29, 2020 16:36
-
-
Save vfontjr/26edc40a382cfebd546a7dbb674636f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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