SHARE
TWEET

Untitled

a guest Jul 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * This will create a WordPress page everytime this hook runs. (i.e. When a user is added via WP Zapier plugin)
  4.  * Add the below code to a custom plugin / child theme functions.php
  5.  */
  6.  function my_wp_zapier_create_post_example( $user_id ) {
  7.  
  8.     $post_data = array(
  9.         'post_title' => 'The post title via wp_insert_post',
  10.         'post_content' => 'Place all your body content for the post in this line.',
  11.         'post_status' => 'publish', // Automatically publish the post.
  12.         'post_author' => $user_id,
  13.         'post_category' => array( 1, 3 ) // Add it two categories.
  14.         'post_type' => 'page' // defaults to "post". Can be set to CPTs.
  15.     );
  16.  
  17.     // Lets insert the post now.
  18.     wp_insert_post( $post_data );
  19.  
  20. }
  21. add_action( 'wp_zapier_after_create_user', 'my_wp_zapier_create_post_example', 10, 1 );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top