Solved

Wordpress: hide custom field array

Posted on 2014-04-25
3
365 Views
Last Modified: 2014-05-25
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
Comment
Question by:St_Aug_Beach_Bum
  • 2
3 Comments
 
LVL 24

Expert Comment

by:lenamtl
ID: 40032365
Do you mean grayed fields with visible info (not editable but visible) or completely invisible fields?
0
 

Accepted Solution

by:
St_Aug_Beach_Bum earned 0 total points
ID: 40077572
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
 

Author Closing Comment

by:St_Aug_Beach_Bum
ID: 40089274
Found own solution.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now