问题
I want to programatically create a Blog/Site in Wordpress Muti site (Networking enabled wordpres). Is there any API to do that? If Not, Can I directly insert the data into the data base?
I want to create a wordpress site based on one of my custom registration forms from a php page. Any Help/Links to the documentation will be appreciated. Thank you.
回答1:
this works for sub directory installs:
global $current_site;
wpmu_create_blog( $current_site->domain, $current_site->path . 'mysite/', 'My Site', 1 );
and this should work for sub domain installs:
global $current_site, $base;
wpmu_create_blog( 'mysite.mydomain.com', $base, 'My Site', 1 );
if you need to add a blog with and a user at the same time, check out the code in /wp-admin/ms-edit.php around where it says 'case 'addblog':' on line 139. THere is code to sanitze the domain, following there is code to add a new user from an email.
来源:https://stackoverflow.com/questions/5307266/wordpress-multi-site-networking-enabled