Object of class Auth\Model\Auth_Group could not be converted to string
The line indicates is the line from the example:
echo 'Driver: ',$info[0],' with group ID ',$info[1],'<br />';
If I echo out just $into[0[ I get ""Ormgroup". If I print_r() out $info[1] I get an Auth\Model\Auth_Group Object.
Could someone please point me in the direction of what I am doing wrong? This seems like it should be simple enough. The user is logged in and I am able to obtain the user ID so Auth itself is working...
That explains things then... The documentation on the site for ORMauth is wrong then unfortunately :(.
Do you know if there is any correct documentation anywhere on how to use the ORM model returned by ORMauth? I'm afraid I'm not following how to properly interface with this now. Looking through the ORM docs I'm not sure how to adapt it to this type of use.
According to the code, get_groups returns array('Ormgroup, $user->group)).
$user->group is a one-to-many relation, which means it's an array of zero or more group objects. So $info[1] is not an object, it's an array of objects.
Reason for this is that contrary to Simpleauth, in Ormauth a user can be member of multiple groups.
I'm seeing it returning an array of array(array('Ormgroup', $this->user->group)); -- Note an array within an array. This is in v1.7 in the ormauth.php. $this->user->group is indeed a single object for me, not a one-to-many relation.
This gets the value from the group_id field in the users table. I'm not sure how it goes about returning multiple groups-- perhaps that is with the group() method?
Anyways, the code I'm successfully using is:
$groups = Auth::get_groups();
foreach( $groups as $group ) {
echo 'Group ID is ',$group[1]->id,' and Group Name is ',$group[1]->name;
}
A modified example from the current SimpleAuth docs can be found here:
You're right, I should have checked the model code too.
It's defined as Group -> hasmany -> User, User -> belongsto -> Group.
So there is only one group possible per user (which is probably done for compatibility with Simpleauth). It returns a nested array because you can have multiple group drivers active, and each will return an array with the driver name and the group.