这个插件是针对Joomla 1.5.x版本的
使用这个插件的目的是用户注册后,需要管理员审核通过后,才能使用。
代码如下:
<?php
defined(’_JEXEC’) or die( ‘Restricted access’ );
jimport(’joomla.plugin.plugin’);
class plgUserBlockuser extends JPlugin {
function plgUserBlockuser(& $subject, $config)
{
parent::__construct($subject, $config);
}
function onAfterStoreUser($user, $isnew, $succes, $msg)
{
if ($isnew)
{
$u=$this->_getUser($user);
$u->set(’block’,1);
$u->save();
}
}
function &_getUser($user, $options = array())
{
$instance = new JUser();
if($id = intval(JUserHelper::getUserId($user['username']))) {
$instance->load($id);
return $instance;
}
jimport(’joomla.application.component.helper’);
$config = &JComponentHelper::getParams( ‘com_users’ );
$usertype = $config->get( ‘new_usertype’, ‘Registered’ );
$acl =& JFactory::getACL();
$instance->set( ‘id’ , 0 );
$instance->set( ‘name’ , $user['fullname'] );
$instance->set( ‘username’ , $user['username'] );
$instance->set( ‘password_clear’ , $user['password_clear'] );
$instance->set( ‘email’ , $user['email'] ); // Result should contain an email (check)
$instance->set( ‘gid’ , $acl->get_group_id( ”, $usertype));
$instance->set( ‘usertype’ , $usertype );
$autoregister = isset($options['autoregister']) ? $options['autoregister'] : $this->params->get(’autoregister’, 1);
if($autoregister)
{
if(!$instance->save()) {
return JError::raiseWarning(’SOME_ERROR_CODE’, $instance->getError());
}
} else {
$instance->set( ‘tmp_user’, true );
}
return $instance;
}
}
本文介绍了一个针对Joomla 1.5.x版本的插件,该插件用于实现用户注册后需经管理员审核才能激活账号的功能。插件通过修改用户状态来确保未审核的账户无法登录。

1万+

被折叠的 条评论
为什么被折叠?



