0

I'm using Magento 1.9.2.4 and i tried to create a user using this code that i found in someone else's answer:

define( 'USERNAME', 'supermanXX' );
define( 'PASSWORD', 'supermanXX' );
define( 'FIRSTNAME', 'Super' );
define( 'LASTNAME', 'Man' );
define( 'EMAIL', 'iam@supermanxx.com' );
include_once( 'app/Mage.php' );
Mage::app( 'admin' );
try {
    $adminUserModel = Mage::getModel( 'admin/user' );
    $adminUserModel->setUsername( USERNAME )
        ->setFirstname( FIRSTNAME )
        ->setLastname( LASTNAME )
        ->setEmail( EMAIL )
        ->setNewPassword( PASSWORD )
        ->setPasswordConfirmation( PASSWORD )
        ->setIsActive( true )
        ->save();
    $adminUserModel->setRoleIds( array( 1 ) )  // HERE
        ->setRoleUserId( $adminUserModel->getUserId() )
        ->saveRelations();
    echo 'User created.';
} catch( Exception $e ) {
    echo $e->getMessage();
}

But then i had a not so smart idea to add more than one RoleIds in the array:

$adminUserModel->setRoleIds( array( 1,2,3 ) )

Now every time i'm trying to log in with whichever user(that worked before) i get this error:

There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 392507181744

How do i delete that user(and remove its roles)? :-s

  • What error does it show in the log: 392507181744? – Danilo Oct 11 '18 at 15:39
  • Hey @Danilo, i solved the problem by writing a stand alone php script with which i deleted that user and all it's roles from admin_role :D but thank you soooo much for taking time to answer to my question!!! :D<3 – emma Oct 11 '18 at 15:40
  • 1
    I'm glad to hear that you solved your problem. – Danilo Oct 11 '18 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.