My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
API  
Application Programming Interface
Featured
Updated Sep 20, 2010 by mish...@gmail.com

User data

@param user id not required (default return current user)
@return user object or false

$userObject = Yii::app()->getModule('user')->user(); // Public Properties: id, username, email, createtime, lastvisit and profile relation
$profileObject = $userObject->profile;               // Your custom fields (Default: firstname, lastname, about)

Is admin

@return true or false

Yii::app()->getModule('user')->isAdmin()

Access control

@return array superusers names

Yii::app()->getModule('user')->getAdmins()

Example controller

	public function accessRules()
	{
		return array(
			array('allow',  // allow all users to perform 'index' and 'view' actions
				'actions'=>array('index','view'),
				'users'=>array('*'),
			),
			array('allow', // allow authenticated user to perform 'create' and 'update' actions
				'actions'=>array('create','update'),
				'users'=>array('@'),
			),
			array('allow', // allow admin user to perform 'admin' and 'delete' actions
				'actions'=>array('admin','delete'),
				'users'=>Yii::app()->getModule('user')->getAdmins(),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

See FieldWidget

Comment by fred...@gmail.com, Dec 23, 2010

I am trying get atributes (username, id) with $userObject = Yii::app()->getModule('user')->user(); in SiteController? action upload and always return user guest.

thx

Comment by hiep8...@gmail.com, Jun 21, 2011

How do I change language in yiiuser extensions?? Please help me!

Comment by laci.ko...@gmail.com, Jul 4, 2011

in /protected/config/main.php add

return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'My Web Application',
        ...
	'language'=>'sk', //-- add your language code here
        ...
      	// preloading 'log' component
	'preload'=>array('log'),
Comment by saulo.cavalcante@gmail.com, Jul 13, 2011

Doesn't the language work if it's have a ""?

config/main.php 'language' => 'pt_br',

$ cat protected/modules/user/messages/pt_br/user.php | grep profile

'Your profile' => 'Seu perfil',
'Edit profile' => 'Editar perfil',

<?php echo UserModule?::t('Edit profile'); ?> == Edit profile

Comment by alix.fal...@gmail.com, Aug 22, 2011

I'm using this:

$userObject = Yii::app()->getModule('user')->user(); $profileFields = $userObject->profile;

but, it send me error at: Trying to get property of non-object .

I saw that Yii don't know $userObject & $profileFields. Someone can help me plz ?

Comment by jerry...@gmail.com, Aug 22, 2011

For some reasons, the file upload widget doesn't work the first time when people register. However, after they registered, they are able to upload the profile photos. Bug?

Comment by MarcLav1...@gmail.com, Apr 16, 2012

I’ve recently installed the yiiuser extension and I am trying to customise the registration form instead of using the auto generated one.

I am trying to use create a drop down list using the same functionality the extension uses.

1.yii user code 2.} elseif ($field->range) { 3. echo $form->dropDownList($profile,$field->varname,Profile::range($field->range));yii user code } elseif ($field->range) {

echo $form->dropDownList($profile,$field->varname,Profile::range($field->range));
so my code looks like this:

1. labelEx($profile,'altType'); ?> 2. dropDownList($profile,'altType',Profile::range($profile->altType->range)); ?> 3. error($profile,'altType'); ?> labelEx($profile,'altType'); ?>

dropDownList($profile,'altType',Profile::range($profile->altType->range)); ?> error($profile,'altType'); ?>

I got the label and drop down appearing on my new form, but the dropdown is empty.

What am I missing?


Sign in to add a comment
Powered by Google Project Hosting