Title: &#8216;wpcf7_posted_data&#8217; not working?
Last modified: July 23, 2018

---

# ‘wpcf7_posted_data’ not working?

 *  [tsjippy](https://wordpress.org/support/users/tsjippy/)
 * (@tsjippy)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/wpcf7_posted_data-not-working/)
 * I am trying to add a custom field to my contact form 7 post data. Here is my 
   code:
 *     ```
       add_filter( 'wpcf7_posted_data', 'action_wpcf7_posted_data', 10, 1 );
   
       function action_wpcf7_posted_data( $array ) { 
       $array['paymentoption'] = "test";
   
       return $array;
       }
       ```
   
 * However, the array is not changed. When I submit the form , the value of “paymentoption”
   is not changed to test.
 * I also tried `$array['paymentoption'][0] = "test";`
 * That did not help.
 * Any clues?

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

 *  Thread Starter [tsjippy](https://wordpress.org/support/users/tsjippy/)
 * (@tsjippy)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/wpcf7_posted_data-not-working/#post-10524210)
 * I tried something totally different to achieve the same result but that fails
   as well:
 * [codex](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_(action))
 * So I have added `<input type="hidden" name="action" value="add_foobar">`to the
   form, and this to my functions.php:
 *     ```
       function prefix_admin_add_foobar(){ 
           status_header(200);
           var_dump($_POST);
           // wp_redirect( 'http://any.url/',302 ); 
           die("Server received '{$_POST['name']}' from your browser.");
   
       }
   
       add_action( 'admin_post_add_foobar', 'prefix_admin_add_foobar' );
       add_action( 'admin_post_nopriv_add_foobar', 'prefix_admin_add_foobar' ); // this is for non logged users
       ```
   
 * does not work…
 *  Thread Starter [tsjippy](https://wordpress.org/support/users/tsjippy/)
 * (@tsjippy)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/wpcf7_posted_data-not-working/#post-10524223)
 * This however works:
    `<form action="<?php echo esc_url( admin_url('admin-post.
   php') ); ?>?action=add_foobar" method="post">`
 * But I have no clue how to add that to a contact form
 *  Thread Starter [tsjippy](https://wordpress.org/support/users/tsjippy/)
 * (@tsjippy)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/wpcf7_posted_data-not-working/#post-10525276)
 * Now have the same headers:
 *     ```
       <form action="https://www.tastedelft.nl/wp-admin/admin-post.php?action=add_foobar" method="post" class="wpcf7-form" novalidate="novalidate">
       ```
   
 * My custom form does a redirect, the Contact form 7 does not.
 * my whole custom, working form:
 *     ```
       <form action="https://www.tastedelft.nl/wp-admin/admin-post.php?action=add_foobar" method="post" class="wpcf7-form" novalidate="novalidate">
          <input name="name" placeholder="Enter email" type="text">
          <button type="submit" class="btn btn-primary">Submit</button>
       </form>
       ```
   

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

The topic ‘‘wpcf7_posted_data’ not working?’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 3 replies
 * 1 participant
 * Last reply from: [tsjippy](https://wordpress.org/support/users/tsjippy/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/wpcf7_posted_data-not-working/#post-10525276)
 * Status: not resolved