eZ Community » Forums » General » Php : How to log user in a certain...
expandshrink

Php : How to log user in a certain siteaccess ?

Php : How to log user in a certain siteaccess ?

Wednesday 06 July 2011 4:29:27 pm - 2 replies

Hi,

How can i log a user in a certain siteacces using the php api ?

There is eZUser::loginUser() but it only log people in current siteaccess.

Is there a way to login people in a different siteaccess which is on the same ezpublish install ?

Thursday 08 March 2012 5:22:37 pm

Hi,

I don't know if this is still actual, but in case anybody is interested :

<?php

--------------------------------------------------------------------------

// First change your siteaccess to the one that you want to log the user on

eZSiteAccess::change(array( 'name' => 'your_siteaccess_name', 'type' => eZSiteAccess::TYPE_DEFAULT  ));

// Force changing the db to current siteacces db

$db = eZDB::instance(false, false, true);

eZDB::setInstance($db);

// Get the user that you want to log in by it's username

$userToLogin = eZUser::fetchByName('your_username');

// Finally log in the user

$userToLogin->loginCurrent();

--------------------------------------------------------------------------

?>

Modified on Thursday 08 March 2012 5:23:05 pm by Bogdan Vâlsan

Thursday 08 March 2012 6:08:45 pm

Great thank you !

Gonna try that solution.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from