Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Last active August 29, 2015 14:11
Show Gist options
  • Save designbuildtest/16da0b7ce25c313034ec to your computer and use it in GitHub Desktop.
Save designbuildtest/16da0b7ce25c313034ec to your computer and use it in GitHub Desktop.
// I am using Gravity Forms together with the 'User Registration' and 'PayPal Standard' Add-On's
// to create new sites on a Multisite network.
// Upon confirmation of a successful PayPal payment, a new site is created with some default pages
// created and custom options applied.
// An abbreviated version of my new site creation function is shown below:
function new_site_setup($blog_id) {
switch_to_blog($blog_id);
wp_delete_post(1, true);
wp_delete_post(2, true);
$default_pages = array(
array(
'type' => 'page',
'title' => __('Home', 'textdomain'),
'content' => __('Home text.', 'textdomain'),
),
array(
'type' => 'page',
'title' => __('About Us', 'textdomain'),
'content' => __('About Us text.', 'textdomain'),
),
array(
'type' => 'page',
'title' => __('Contact', 'textdomain'),
'content' => __('Contact text.', 'textdomain'),
),
);
foreach ($default_pages as $var) {
$data = array(
'post_type' => $var['type'],
'post_title' => $var['title'],
'post_content' => $var['content'],
'post_status' => 'publish',
'post_author' => 1,
'comment_status' => 'closed',
'ping_status' => 'closed',
);
wp_insert_post(add_magic_quotes($data));
}
update_option('show_on_front', 'page');
update_option('page_on_front', 3);
update_option('show_avatars', 0);
update_option('use_smilies', 0);
restore_current_blog();
}
add_action('wpmu_new_blog', 'new_site_setup');
// My Gravity Forms signup form is currently pretty basic requiring just a name, email address,
// site name and recurring payment amount.
// I would like to extend my signup form and include two additional select fields that enable the
// user to nominate a site language and starter theme.
// Gravity Forms would then pass the language and theme values to my new site creation function
// and update the requisite database options.
update_option('WPLANG', $language);
update_option('current_theme', $theme_name);
update_option('template', $theme_slug);
update_option('stylesheet', $theme_slug);
// Please can someone suggest a Gravity Forms filter, function or technique that would enable me to
// set site language and theme values after confirmation of a successful PayPal payment.
// I would also like the author of the default pages to be the new user rather than the super admin
// as I have coded currently.
// Thank you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment