用户注册后禁用的Joomla插件

这个插件是针对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;
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值