Title: How to filter custom fields?
Last modified: August 20, 2016

---

# How to filter custom fields?

 *  [Viruthagiri](https://wordpress.org/support/users/viruthagiri/)
 * (@viruthagiri)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/how-to-filter-custom-fields/)
 * I’m using cubepoints. It has a module named “paid content”. Paid content module
   hides the post content. User need to pay “X” points to view the page. But this
   module only hides main content. I mean it hides the content whatever “the_content”
   loop calls.
 * Here is my problem. I’m using magic fields plugin. It is a plugin to create custom
   fields.
    So my site doesn’t use the_content loop.
 * For example this is the code my theme uses instead of the_content loop.
 *  `<?php if (function_exists(‘get_field’)) {
    $requirements = get_field(‘requirements_requirements’);
   if($requirements){ foreach($requirements as $requirement){ echo $requirement;}}}?
   >`
 * Now i want to hide these custom field contents.
    This is the full source code
   of paid content module.
 * [http://pastebin.com/MqgdJj6m](http://pastebin.com/MqgdJj6m)
 * The filter function code is from line 187 to line 204 (see the code below).
 *  `function cp_module_pcontent_post_content($content){
    global $post; global $
   cp_module_pcontent_hide; if(!in_array($post->ID,(array)$cp_module_pcontent_hide)){
   return $content; } $c = ‘<p>’ . get_option(‘cp_module_pcontent_text_pay’) . ‘
   </p>’; $c .= apply_filters(‘cp_module_pcontent_post_content_’.$post->ID, ”); 
   $c .= ‘<form method=”post”>’; $c .= ‘<input type=”hidden” name=”cp_module_pcontent_pay”
   value=”‘.$post->ID.'” />’; $c .= ‘<p><input type=”submit” value=”‘.get_option(‘
   cp_module_pcontent_text_button’).'” /></p>’; $c .= ‘</form>’; if(!is_user_logged_in()){
   $c = get_option(‘cp_module_pcontent_text_logout’); } $c = str_replace(‘%points%’,
   cp_formatPoints(get_post_meta($post->ID,’cp_pcontent_points’, 1)),$c); return
   $c; }`
 * So can anyone alter the code to hide the custom fields?
    Thanks

The topic ‘How to filter custom fields?’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [Viruthagiri](https://wordpress.org/support/users/viruthagiri/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/how-to-filter-custom-fields/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
