Skip to content

Instantly share code, notes, and snippets.

@javierarques
Created January 7, 2014 18:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save javierarques/8304351 to your computer and use it in GitHub Desktop.
Save javierarques/8304351 to your computer and use it in GitHub Desktop.
[WP] Create post with Contact Form 7 post data via wpcf7_before_send_mail hook
add_action('wpcf7_before_send_mail', 'cf7_create_post', 10, 1);
function cf7_create_post( $data ) {
extract($data->posted_data);
$post_id = wp_insert_post( array(
'post_status' => 'draft',
'post_title' => $nombre,
'post_content' => $consulta
));
add_post_meta( $post_id, 'email', $email, true);
}
@IgnacioArregui
Copy link

Hola.

Estoy desarrollando una web en la que necesito crear post a partir de los datos de un formulario (imagen destacada incluída)
¿Tu código hace eso?

Perdona la molestia y muchas gracias
Ignacio Arregui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment