Re: Default pages creation
I can’t provide buddypress specific code as I have not yet read through it, but here is the code that I use to have pages automatically created for new blogs when they are setup.
Anyone with bp experience who knows the function names could easily change my code to bp appropriate code. [replicate the code as often as needed in the custom function file for as many pages as you need]
Code:
function change_newblog_defaults( $blog_id, $user_id ){
global $wpdb, $current_site, $wp_rewrite;
//–change to new blog
switch_to_blog($blog_id);
//make page
$wpdb->insert( $wpdb->posts, array(
‘post_author’ => $user_id,
‘post_date’ => $now,
‘post_date_gmt’ => $now_gmt,
‘post_content’ => __(‘This is the content’),
‘post_excerpt’ => ”,
‘post_title’ => __(‘Pagetitle’),
‘post_name’ => __(‘Pagename’),
‘post_modified’ => $now,
‘post_modified_gmt’ => $now_gmt,
‘post_status’ => ‘publish’,
‘post_type’ => ‘page’,
‘to_ping’ => ”,
‘pinged’ => ”,
‘post_content_filtered’ => ”
) );
//inserted id
$page_id = $wpdb->insert_id;
global $wpdb, $current_site, $wp_rewrite;
//–change to new blog
switch_to_blog($blog_id);
//make page
$wpdb->insert( $wpdb->posts, array(
‘post_author’ => $user_id,
‘post_date’ => $now,
‘post_date_gmt’ => $now_gmt,
‘post_content’ => __(‘This is the content’),
‘post_excerpt’ => ”,
‘post_title’ => __(‘Pagetitle’),
‘post_name’ => __(‘Pagename’),
‘post_modified’ => $now,
‘post_modified_gmt’ => $now_gmt,
‘post_status’ => ‘publish’,
‘post_type’ => ‘page’,
‘to_ping’ => ”,
‘pinged’ => ”,
‘post_content_filtered’ => ”
) );
//inserted id
$page_id = $wpdb->insert_id;
//change template inserted page
$wpdb->query(“insert into $wpdb->postmeta (post_id,meta_key,meta_value) values ($page_id,’_wp_page_template’,’templatefile.php’)”);
//restore blog
restore_current_blog();
}
add_action(‘wpmu_new_blog’, ‘change_newblog_defaults’ );