Fatel Error While Adding User In Group Management

i have create custom user class in custom/module/user/User.php and Custom User class extends with Main User
Example:-
class CUser extends User
{

}
now when i try to add user in group i got below fatal error

Most Welcome to solve this issue

Fatal error* : Uncaught Error: Call to a member function addBean() on string in C:\laragon\www\vikram711\data\Relationships\M2MRelationship.php:140 Stack trace: #0 C:\laragon\www\vikram711\data\Link2.php(547): M2MRelationship->add(Object(SecurityGroup), Object(CUser), Array) #1 C:\laragon\www\vikram711\include\generic\Save2.php(206): Link2->add(Array, Array) #2 C:\laragon\www\vikram711\include\MVC\Controller\SugarController.php(1087): require_once(‘C:\laragon\www\…’) #3 C:\laragon\www\vikram711\include\MVC\Controller\SugarController.php(468): SugarController->handleActionMaps() #4 C:\laragon\www\vikram711\include\MVC\Controller\SugarController.php(373): SugarController->process() #5 C:\laragon\www\vikram711\include\MVC\SugarApplication.php(113): SugarController->execute() #6 C:\laragon\www\vikram711\index.php(52): SugarApplication->execute() #7 {main} thrown in C:\laragon\www\vikram711\data\Relationships\M2MRelationship.php on line *140

Try to do the following:

Create an extended Include (custom/Extension/application/Ext/Include/<somefile.php>):

$moduleList[] = ‘Users’;
$objectList[‘Users’] = ‘User’;
$beanList[‘Users’] = ‘CustomUser’;
$beanFiles[‘CustomUser’] = ‘custom/modules/Users/User.php’;

Create the custom User class (custom/modules/Users/User.php)
require_once(‘modules/Users/User.php’);

class CustomUser extends User {
public function __construct() {
parent::__construct();
$this->disable_row_level_security = false;
}
}

Remember to run Quick Repair and Rebuild

Hi @andopes
Thank you for replying with code, i tried this option but not working.
have any other solution for

It seems it has 2 issues:
1: class M2MRelationship look for object class instead of module dir, this way a custom class will never work as expected to.
2. For some reason the variable $rhsLinkName is getting a string (perhaps the link name) instead of an object (the bean itself), so you may need to figure out why.

Regards

1 Like

Thank you for reposnse