Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • Last Modified:

Wordpress: hide custom field array

Hi,

I want to hide a number of custom fields in the custom field metabox that my users should not be messing with. Just leave the ones they should enter something into.

I found this filter that will hide one custom field:

add_filter( 'is_protected_meta', 'hide_feelings', 10, 2 );
function hide_feelings( $protected, $meta_key ) {
      if ( 'feelings' == $meta_key ) return true;
      return $protected;
}

Is there a way that I can use that but hide a number of fields?

So, for example, if I have:

$mk = array('approver','approver_1','cf_fields','cf_rules');

It would hide all those fields from users?

Thanks for any help,

Chris
0
St_Aug_Beach_Bum
Asked:
St_Aug_Beach_Bum
  • 2
1 Solution
 
lenamtlCommented:
Do you mean grayed fields with visible info (not editable but visible) or completely invisible fields?
0
 
St_Aug_Beach_BumAuthor Commented:
Sorry for the very late reply. Actually worked this out with an &&

ie:

if (('feelings' !== $meta_key) && ('feelings2' !== $meta_key)) return true;

Seems like that should have to be an ||, but this is what works.....

hmm.

Thank you for offering to help though.

Chris
0
 
St_Aug_Beach_BumAuthor Commented:
Found own solution.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now