Reputation: 45
I want to programmatically create a blog with a user at the same time on my Word Press MultiSite by directly inserting data into the mySQl database.
Wordpress Multi Site (Networking enabled) seems to be a similar question but I can't seem to implement the solution provided there. Can anyone help with the basics of implementing this?
Upvotes: 1
Views: 1657
Reputation: 1410
You should use wordpress multisite plugin here.You just have to make single method call for creating new blog with your new path in multi-site.Here below is an example that uses apache xml-rpc api
public class Demo
{
public static void main(String[] args)
{
System.out.println("Starting adicXmlRpcServer test");
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try
{
config.setServerURL(new URL("http://localhost/wordpress/xmlrpc.php"));
}
catch (MalformedURLException ex)
{
System.out.println("Invalid url....."+ex.getMessage());
ex.printStackTrace();
}
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Map map = new HashMap();
map.put("domain","localhost");
map.put("path","/newStrore");
map.put("title","newStrore");
map.put("user_id","[email protected]");
Object[] params = new Object[] {new String("admin"),new String("9868"),map};
try
{
Object result = (Object) client.execute("ms.CreateBlog",params);
ArrayList<String> dirListing = new ArrayList<String>();
System.out.println(result.toString());
}
catch (XmlRpcException ex)
{
System.out.println("Invalid url....."+ex.getMessage());
ex.printStackTrace();
}
}
}
Upvotes: 1