Probably via wpmu_new_blog
wpmu_create_blog does this:
* This function runs when a user self-registers a new site as well
* as when a Super Admin creates a new site. Hook to ‘wpmu_new_blog’
* for events that should affect all new sites.
do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
So you want to hook that and have it name a new post 🙂
… like this.
<?php
function ds_new_site_post( $blog_id ) {
switch_to_blog( $blog_id );
$blogname = get_option( 'blogname' );
$siteurl = site_url();
restore_current_blog();
$post_content = sprintf( __( 'New Site: <a href="%2$s">%1$s</a>' ), $blogname, $siteurl);
$post_title = sprintf( __( 'New Site: %1$s' ), $blogname);
$post = array(
'post_content' => $post_content,
'post_title' => $post_title,
'post_status' => 'publish'
);
wp_insert_post( $post );
}
add_action( 'wpmu_new_blog', 'ds_new_site_post' );
Ah okay thank you guys, David, would I be able to just copy and paste that code into my functions file? I’m sorry, I am kind of a noob to this coding with wordpress thing 🙁
https://codex.wordpress.org/Writing_a_Plugin
Add what you like to the plugin header and add to your wp-content/plugins.
(easy peasy tutorial)
Okay so I put the above code into a php document, and uploaded it to my multisites plugin directory and enabled it on the site I wanted it to work on and when a user creates a site it doesn’t pop up as a post, is there something I need to configure?
Actually I was able to figure it out! Thank you again! But just one more thing, if I wanted to setup the post with a specific format (I have 4 formats, standard audio, video, and quote) how would I code that in there?
Custom post types? Add post_type to the $post array. See codex for more details on using wp_insert_post.