Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  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 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement