Title: Server-side filter for custom fields
Last modified: August 31, 2016

---

# Server-side filter for custom fields

 *  Resolved [friendofdog](https://wordpress.org/support/users/friendofdog/)
 * (@friendofdog)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/server-side-filter-for-custom-fields/)
 * I’d like to set a custom field, “current-status”, to “Order received” in all 
   instances. This can be done easily by using a CF7 shortcode [text meta_current-
   status "Order received"]. But seeing as how the value is the same for every user,
   I’d rather set this on the back end.
 * So I thought I’d add a filter into functions.php:
 *     ```
       function form_to_post_set_values($post) {
           $post['meta_order-status'] = 'Order received';
           return $post;
       }
       add_filter('form_to_post_before_create_post', 'form_to_post_set_values')
       ```
   
 * Obviously, this did not work but I think you can see what I’m trying to do here.
   Any suggestions?
 * [https://wordpress.org/plugins/form-to-post/](https://wordpress.org/plugins/form-to-post/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Michael Simpson](https://wordpress.org/support/users/msimpson/)
 * (@msimpson)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/server-side-filter-for-custom-fields/#post-7030825)
 * I see that this is an oversight in the code. This hook allows you to change the
   inputs to the
    wp_insert_post call but the meta fields are not there. The meta
   fields are handled in a subsequent update_post_meta call after the post is created.
 * So I added a new hook. Update to version 0.9 (should be available soon) then 
   use this code:
 *     ```
       function form_to_post_set_meta($post) {
           $post['order-status'] = 'Order received';
           return $post;
       }
       add_filter('form_to_post_before_update_post_meta', 'form_to_post_set_meta');
       ```
   
 *  Thread Starter [friendofdog](https://wordpress.org/support/users/friendofdog/)
 * (@friendofdog)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/server-side-filter-for-custom-fields/#post-7030925)
 * That did it! Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Server-side filter for custom fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/form-to-post.svg)
 * [Form to Post](https://wordpress.org/plugins/form-to-post/)
 * [Support Threads](https://wordpress.org/support/plugin/form-to-post/)
 * [Active Topics](https://wordpress.org/support/plugin/form-to-post/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/form-to-post/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/form-to-post/reviews/)

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)

 * 2 replies
 * 2 participants
 * Last reply from: [friendofdog](https://wordpress.org/support/users/friendofdog/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/server-side-filter-for-custom-fields/#post-7030925)
 * Status: resolved