1 d_black Apr 03, 2012 23:03
3 d_black Apr 04, 2012 19:54
ok, thanks , you don't know is the name of that plugin ?
4 sam2kb Apr 04, 2012 22:16
There's no such plugin, but it's easy to make one.
Here's a complete plugin. Save the code as /plugins/_my.plugin.php
You will also need to delete all unused stub files blog2.php, blog3.php etc. from b2evolution directory.
<?php
/**
* -----------------------------------------------------------------------------------------
* This file provides a skeleton to create a new {@link http://b2evolution.net/ b2evolution}
* plugin quickly.
*/
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
class my_plugin extends Plugin
{
var $name = 'My own plugin';
var $code = 'myplugincode';
var $priority = 50;
var $version = '0.0.1';
function PluginInit( & $params )
{
$this->short_desc = $this->T_('Short description');
$this->long_desc = $this->short_desc;
}
/**
* Event handler: Defines blog settings by its kind. Use {@link get_collection_kinds()} to return
* an array of available blog kinds and their names.
* Define new blog kinds in {@link Plugin::GetCollectionKinds()} method of your plugin.
*
* Note: You have to change $params['Blog'] (which gets passed by reference).
*
* @param array Associative array of parameters
* - 'Blog': created Blog (by reference)
* - 'kind': the kind of created blog (by reference)
*/
function InitCollectionKinds( & $params )
{
switch( $params['kind'] )
{
case 'std': // override standard blog settings
$params['Blog']->set( 'access_type', 'subdom' );
$params['Blog']->set( 'siteurl', '' );
break;
}
}
}
?>
5 d_black Apr 05, 2012 01:04
Thank you very much, it work fine if the new blog is created by admin in the backoffice, but not if it is created by user in the inscription page (front page). It work if user (not admin) create the blog in the backoffice but not in the inscription page (front page) when the new user do the registration. I need new user got automaticly new blog after his inscription but the plugin don't do this.
How can I solve this ?
6 sam2kb Apr 05, 2012 02:03
It's a bug.
Edit the following in /inc/users/model/_user.class.php line 1677
find
if( $Group->check_perm( 'perm_getblog', 'allowed' ) )
{ // automatically create new blog for this user
// TODO: dh> also set locale, or use it at least for urltitle_validate below. From the User (new blog owner)?
$new_Blog = new Blog( NULL );
$shortname = $this->get( 'login' );
$new_Blog->set( 'owner_user_ID', $this->ID );
$new_Blog->set( 'shortname', $shortname );
$new_Blog->set( 'name', $shortname.'\'s blog' );
$new_Blog->set( 'locale', $this->get( 'locale' ));
$new_Blog->set( 'urlname', urltitle_validate( $shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get( 'locale' ) ) );
$new_Blog->create();
}
and replace with
if( $Group->check_perm( 'perm_getblog', 'allowed' ) )
{ // automatically create new blog for this user
$new_Blog = new Blog( NULL );
$shortname = $this->get( 'login' );
$new_Blog->set( 'owner_user_ID', $this->ID );
$new_Blog->set( 'shortname', $shortname );
$new_Blog->set( 'name', $shortname.'\'s blog' );
$new_Blog->set( 'locale', $this->get( 'locale' ));
$new_Blog->set( 'urlname', urltitle_validate( $shortname, $shortname, $new_Blog->ID, false, 'blog_urlname', 'blog_ID', 'T_blogs', $this->get( 'locale' ) ) );
// Defines blog settings by its kind.
$Plugins->trigger_event( 'InitCollectionKinds', array(
'Blog' => & $new_Blog,
'kind' => 'std',
) );
$new_Blog->create();
}
7 d_black Apr 05, 2012 02:16
Realy Thanks !! It work perfectly !! ^^
Welcome to the forum!
Currently you can only do that with a plugin.
Moved to Feature requests...