X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Working with users/Creating Users external (https://forum.x-cart.com/showthread.php?t=71508)

skit 02-27-2015 01:26 PM

Working with users/Creating Users external
 
If you can create a user with the following:

$profile->setLogin('bit-bucket@x-cart.com');
$profile->setPassword(\XLite\Core\Auth::encryptPassword('te ster'));

Is there a way to set the user access level to Admin instead of Customer?

Any help is appreciated.

Thanx

totaltec 03-02-2015 09:59 AM

Re: Working with users/Creating Users external
 
Maybe try
Code:

$profile->setAccessLevel(100);
Just guessing. Curious if it works!

skit 03-02-2015 11:44 AM

Re: Working with users/Creating Users external
 
totaltec.. I tried that and it does set them as administrator but the Administrator role still has be be added to "roles".

In other words.. It sets the "Access Level" to administrator under the user tab but it will not add the Administrator the "Roles".

skit 03-03-2015 07:15 AM

Re: Working with users/Creating Users external
 
totaltec, Thanks for the advice.

I tried that and it does set the Access level to Administrator but to full work it also needs to set the "Roles" as Administrator. Or, add the Administrator to the Roles.

totaltec 03-03-2015 04:30 PM

Re: Working with users/Creating Users external
 
Quote:

Originally Posted by skit
totaltec, Thanks for the advice.

I tried that and it does set the Access level to Administrator but to full work it also needs to set the "Roles" as Administrator. Or, add the Administrator to the Roles.


Looks a little tougher to figure this part out. Something like $profile->addPermissions($permissions), but I am not sure what the value of $permissions should be! Or if that method is even accessible to that object.

I'm shooting in the dark here, glad the first bit worked. Perhaps Tony or someone else with knowledge can shed some light. I could certainly work this out for you, but I can't do it off the top of my head without research.

skit 03-04-2015 05:49 AM

Re: Working with users/Creating Users external
 
I think I got it. You have to add the role after the user is created.

$profile->addRoles($role);
$profile->create();
$role->addProfiles($profile);


All times are GMT -8. The time now is 06:46 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.