Wordpress 多站点(启用网络) [英] Wordpress Multi Site (Networking enabled)
问题描述
我想以编程方式在 Wordpress Muti 站点(启用网络的 wordpres)中创建一个博客/站点.是否有任何 API 可以做到这一点?如果不是,我可以直接将数据插入数据库吗?
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?
我想根据我的一个自定义注册表单从 php 页面创建一个 wordpress 站点.任何帮助/文档链接将不胜感激.谢谢.
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.
推荐答案
这适用于子目录安装:
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 );
如果您需要同时添加一个博客和一个用户,请查看/wp-admin/ms-edit.php 中的代码,该代码在第 139 行显示case 'addblog':"的地方.是清理域的代码,下面是从电子邮件添加新用户的代码.
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.
这篇关于Wordpress 多站点(启用网络)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!