I will try to explain how you can use wordpress MU (2.8.4)  inside your joomla (1.5)  to create blogs for your joomla users automatically.

you will not want  every joomla user to have blogs without actually user wants it to create.

keeping it in mind we follow these things.

1)  install wordpress MU inside your joomla main installation directory (i.e if my joomla is installed in ABC/joomla then I would install wordpress inside ABC/Joomla/wordpress

2) when installing your wordpress keep the database same as joomla is using (remember you should not have ur joomla tables prefix “wp_” if it is so then change your joomla tables prefix to something else)

3) configure your wordpress.

4) now come to the button or link on your registered joomla user page where you want to give user an option to create wordpress blogs.

5) following functions you should have



function  getUserValue($id,$field){

$db      =& JFactory::getDBO();
$query="SELECT $field from #__users Where id=".$id;
$db->setQuery($query);
$result=$db->loadObject($field);

//if(strlen($result->$field)<100){
return nl2br($result->$field);
// }else{
//return ;
//  }

}

function isBlogActive($username){
$db      =& JFactory::getDBO();
$query="SELECT COUNT(*) FROM wp_blogs Where domain='".$username.".<span style="color: #993300"><strong><em>yourdomain</em></strong></span>.com'";
//echo $query;

$db->setQuery($query);
//echo $db->stdErr();
$results=$db->loadResult();

//echo $results;

return $results;

}

#### now paste given below where you want to give user an option to create  blog

</pre>
<pre><?php
 $user=& JFactory:getUser();
$id=$user->get('id);
if(isBlogActive(getUserValue($id,'username'))){
echo '<a href="http://'.getUserValue($id,'username').'.<span style="color: #993300"><strong>yourdomain</strong></span>.com">
MY BLOGS</a>';
}else{

?>

<form method="post" action="/wordpress/wp-admin/wpmu-edit.php?action=addblog">
<input name="blog[createblog]" type="hidden" title="<span style="color: #0000ff">some key</span>" value="<span style="color: #0000ff">some key</span>"/>
<input name="blog[domain]" type="hidden"
title="<?php echo getUserValue($id,'username'); ?>"
value="<?php echo getUserValue($id,'username'); ?>"/>

<input type="hidden" name="blog[title]"  size="20"
title="<?php echo getUserValue($id,'name'); ?>"
value="<?php echo getUserValue($id,'name'); ?>"/>

<input type="hidden" name="blog[email]"  size="20"
title="<?php echo getUserValue($id,'email'); ?>"
value="<?php echo getUserValue($id,'email'); ?>"/>

<input type="submit" name="go" id="go"
Value="Add <?php echo getUserValue($id,'name');?> Blogs" >

</form>

 <?php

 }
 ?>

##################################

6) now come to wordpress/wp-admin/wpmu-edit.php file to make some changes

#######CHANGE FROM:##########################

if( is_site_admin() == false ) {
wp_die( __('You do not have permission to access this page.') );
} do_action('wpmuadminedit', '');
if( isset($_GET[ 'id' ]) ) {
$id = intval( $_GET[ 'id' ] );
} elseif( isset($_POST[ 'id' ]) ) {
$id = intval( $_POST[ 'id' ] );
}
if( isset( $_POST['ref'] ) == false && !empty($_SERVER['HTTP_REFERER']) ) {
$_POST['ref'] = $_SERVER['HTTP_REFERER'];
}

#######################  CHANGE TO:##########

$blog = $_POST['blog'];

if($blog['createblog']=='<span style="color: #0000ff">some key</span>'){

}else{

if( is_site_admin() == false ) {
wp_die( __('You do not have permission to access this page.') );
}

do_action('wpmuadminedit', '');

if( isset($_GET[ 'id' ]) ) {
$id = intval( $_GET[ 'id' ] );
} elseif( isset($_POST[ 'id' ]) ) {
$id = intval( $_POST[ 'id' ] );
}

}

7)  go to case “addblog”: line  in wpmu-edit.php and replace check_admin_referer(’add-blog’); line with


$blog = $_POST['blog'];
if($blog['createblog']=='<span style="color: #0000ff"><strong>some key</strong></span>'){
}else{
check_admin_referer('add-blog');
}
8) open admin.php in same directory and comment the line auth_redirect();

to

//auth_redirect();

################

DO NOT FORGET TO CHANGE “some key” and “yourdomain“.

and you are done with it but make sure your wordpress is configured to send user login/passwd after their registeration so that user can get his blog pasword otherwise use “configure smtp” plugin to send mail using gmail or google hosted emails.

HAPPY BLOGGING

http://www.linksutra.com