SHARE
TWEET

Set page template and create a page, not a post

chrishajer Mar 23rd, 2013 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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