Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a new Wordpress page after making a new form and embed the new Gravity Form in it
/**
* Create a new Wordpress page after making a new form
* and embed the new Gravity Form in it
*/
add_action("gform_after_save_form", "actonregister_create_page", 10, 2);
function actonregister_create_page($form, $is_new){
$user = wp_get_current_user();
if($is_new){
$page_id = wp_insert_post(array(
'post_title' => $form["title"],
'post_author' => $user->id,
'post_type' => 'page',
'post_name' => sanitize_title($form["title"]),
'post_status' => 'publish',
'post_excerpt' => $form["description"],
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_content' => '[gravityform id="' . $form["id"] . '" title="false" description="false" ajax="true"]'
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment