rakyaninfotech.com

Our Contact


Rakyan Infotech
22 Strand Road
Kolkata 700001
INDIA
+9122311123
info@rakyaninfotech.com

Wordpress – Create multiple blog

If you want to create multiple blog in wordpress from your site then it can be done in wordpress 3 and above

Following code in php does the work

require("wp-config.php");
require_once( ABSPATH . WPINC . '/registration.php');
$keyword = $_GET['keyword'];
if ($keyword!='xvfp78960'){echo "invalid request";die();}
$operation = $_GET['operation'];
switch ($operation){
case "checkuser":
$checkuser=isuser($_GET['username']);
if (!$checkuser){
echo 0;
}else{
echo $checkuser;
}
return;
break;
case "newblog":
$username= $_GET['username'];
$password= $_GET['password'];
$email= $_GET['email'];
$domain= $_GET['domain'];
$path= $_GET['path'].$username;
$title=$username."'s blog at lifo.com";
$blogid=create_blog($username,$password,$title,$email,$domain,$path);
echo $blogid;
break;
}
function create_blog($username,$password,$title,$email,$domain,$path){
if (username_exists($username)>0){
return -1;
}

$user_id= wpmu_create_user($username,$password,$email);
if (!is_wp_error($user_id) && $user_id!=”){
$blogid=wpmu_create_blog($domain, $path, $title, $user_id, $meta = ”, $user_id);
if (is_wp_error($blogid)){
$blogid=$blogid->get_error_message();
}
return $blogid;
}else{
return “blog already exists with your email address”;
}

}

function isuser($username){
return username_exists($username);
}

?>

Published by admin on September 8th, 2010 Tagged web scripts

Comments are closed.