Advertisement
chrishajer

Set page template and create a page, not a post

Mar 23rd, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2. // http://www.gravityhelp.com/forums/topic/automatic-sign-up-page-generating-a-new-web-page-or-post#post-179371
  3. // the 10 (priority), 2 (arguments) is documented here http://codex.wordpress.org/Function_Reference/add_filter
  4. // change the 5 here to your form ID
  5. add_action('gform_after_submission_5', 'update_page_settings', 10, 2);
  6. function update_page_settings($entry, $form){
  7.  
  8.     // get the post
  9.     $post = get_post($entry['post_id']);
  10.  
  11.     // create a page, not a post
  12.     $post->post_type = 'page';
  13.  
  14.     // set the page template
  15.     update_post_meta($post_id, '_wp_page_template', 'template-my-form.php');
  16.  
  17.     // update the post
  18.     wp_update_post($post);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement