wp_insert_post_data

We need to make sure that the post author is always zero for contact form submissions.

Description

add_filter( 'wp_insert_post_data', (array) $array, (int) $int, (int) $int ); 

This prevents export/import from trying to create new users based on form submissions from people who were logged in at the time.

Unfortunately wp_insert_post() tries very hard to make sure the post author gets the currently logged in user id. That is how we ended up with this work around.

Parameters (3)

0. $array (array) => array( $plugin, 'insert_feedback_filter' )
The array.
1. $int (int) => 10
The int.
2. $int (int) => 2
The int.

Usage

To run the hook, copy the example below.
  1. $array = apply_filters( 'wp_insert_post_data', $array, $int, $int ); 
  2.  
  3. if ( !empty( $array ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_insert_post_data callback 
  2. function filter_wp_insert_post_data( $array, $int, $int ) { 
  3. // make filter magic happen here... 
  4. return $array
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_insert_post_data', 'filter_wp_insert_post_data', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_insert_post_data', 'filter_wp_insert_post_data', 10, 3 ); 

Defined (4)

The filter is defined in the following location(s).

/modules/contact-form/grunion-contact-form.php  
  1. add_filter( 'wp_insert_post_data', array( $plugin, 'insert_feedback_filter' ), 10, 2 ); 
  1. remove_filter( 'wp_insert_post_data', array( $plugin, 'insert_feedback_filter' ), 10 ); 
/modules/markdown/easy-markdown.php  
  1. add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 ); 
  1. remove_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 );