?
Solved

Wordpress: hide custom field array

Posted on 2014-04-25
3
Medium Priority
?
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

765 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