wp_insert_post_data
We need to make sure that the post author is always zero for contact form submissions.
Description
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.
- $array = apply_filters( 'wp_insert_post_data', $array, $int, $int );
- if ( !empty( $array ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the wp_insert_post_data callback
- function filter_wp_insert_post_data( $array, $int, $int ) {
- // make filter magic happen here...
- return $array;
- };
- // add the filter
- add_filter( 'wp_insert_post_data', 'filter_wp_insert_post_data', 10, 3 );
- To remove a hook callback, use the example below.
- // remove the filter
- 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
- add_filter( 'wp_insert_post_data', array( $plugin, 'insert_feedback_filter' ), 10, 2 );
- remove_filter( 'wp_insert_post_data', array( $plugin, 'insert_feedback_filter' ), 10 );
- /modules/markdown/easy-markdown.php
- add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 );
- remove_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 );