- b2evolution CMS Support Forums
- b2evolution Support
- General Support
- Writing to htaccess for redirect using Autoblog
1 source Jan 27, 2008 17:45
My b2evolution Version: Not Entered
Hi
Im a new user, discovered the amazing b2e.
Im using autoblog at the moment and it is working fine. The thing is ive setup b2e in a subdirectory http://mysite.com/blog now when new users create a new blog it makes http://mysite.com/blog/username.
Is there a way using my setup to create a redirect so the the users just need to type in http://mysite.com/username to get them to http://mysite.com/blog/username?
I was looking at the _autoblog.plugin.php file and at around line 109 the new user and blog is created after the registration page.
Ive added something extra to it for it to write the redirect to the htaccess file in the root.
function AfterUserInsert( $params )
{
global $UserSettings;
$inserted_User = $params['User'];
// Check if user wants autoblog in registration form
if( param('autoblog_wanted') ){
$UserSettings->set('autoblog_created', 'wanted', $inserted_User->ID);
$UserSettings->dbupdate();
$this->CreateAutoBlog( $params );
$myFile = "../../.htaccess";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "\n redirect code goes here \n";
fwrite($fh, $stringData);
fclose($fh);
}
It works but the problem is i dont know how to get the username string to put in the $stringData. Does anyone know how to get it? Once you get that then the redirects can be made.
Not really sure, but since it looks like $inserted_User->ID has value you might be able to use something like $inserted_User->get( 'login' ) to make it happen.
Another thing that I do frequently is to throw the Object (or Array or whatever they are) on the screen with
That way I would know what kind of stuff I can pick up from $inserted_User, then try it with ->thing or ->get( 'thing' ).
Hope it helps! The autoblog plugin was super-cool but it doesn't seem supported by the author anymore. Such is life yah?