Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Wordpress: hide custom field array

Posted on 2014-04-25
3
Medium Priority
?
388 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
Suggested Courses

610 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