Good morning everyone! I need your help guys.
We have a site which offers blogging engine as a feature. WPMU is installed on a separate domain (i.e. blog.domain.com). WPMU user must be created automatically when user is registered on our site (i.e. domain.com) and after logging in they can create a blog without going to blog.domain.com. To accomplish this i created following file and dropped on blog.domain.com.
<?php
if(isset($_REQUEST['function'])){
$functionName = $_REQUEST['function'];
$arguments = explode(",", $_REQUEST['args']);
}
/** Include the bootstrap for setting up WordPress environment */
include('./wp-load.php');
require_once( ABSPATH . WPINC . '/registration.php');
require_once('FirePHPCore/FirePHP.class.php');
$firephp = FirePHP::getInstance(true);
if($functionName == "wpmu_create_blog"){
$newdomain = $arguments[0].".".$current_site->domain;
$blog_title = $arguments[1];
$user_id = $arguments[2];
$res = wpmu_create_blog($newdomain, $base, $blog_title, $user_id, array( "public" => 1 ), $current_site->id);
$firephp->log($res);
if ( is_wp_error($res) ) {
$result["message"] = $res->get_error_messages();
$result["status"] = false;
} else {
$blog_id = $res;
$result["status"] = true;
$result["blog_id"] = $blog_id;
$result["blog_url"] = "http://".$newdomain.$base;
add_user_to_blog( $blog_id, $user_id, 'author' );
}
$result = json_encode($result);
} else if($functionName == "wpmu_create_user"){
$res = wpmu_create_user(wp_specialchars( strtolower( $arguments[0] ) ), $arguments[1], wp_specialchars( $arguments[2] ) );
if ( $res == false ) {
$result["message"] = "Duplicated username or email address.";
$result["status"] = false;
} else {
$result["status"] = true;
$result["blog_user_id"] = $res;
}
$result = json_encode($result);
} else {
$result = json_encode(call_user_func_array($functionName, $arguments));
}
$firephp->log($result);
echo $result;
?>
And it works fine. The problem is that when i create testuser and testblog and login to my WP dashboard i see two blogs: testblog which is located at testblog.blog.domain.com and the main blog which is located at blog.domain.com. Also testuser has 'Administrator' role on testblog. But ideally we should have:
1. testuser must not see our main blog
2. testuser must have 'Author' role on his own blog
Is it possible without changing WPMU code? If so, what should i change in my code to implement above 2 rules.
Thanks in advance!