Wordpress Multi Site (Networking enabled)

对着背影说爱祢 提交于 2019-12-12 09:03:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!