[Vtigercrm-developers] Help creating user via api

Alexander Allen Z alexander.allenz at gmail.com
Tue Dec 12 23:36:48 GMT 2023


>
> Thank you Allan. Trying this query as in the link you sent me I get the
> same error message.
>
> Code :
> include_once 'include/Webservices/Utils.php';
> $crmid = '1'; // ID of Leads record.
> $wsid = vtws_getWebserviceEntityId('Users', $crmid);
> include_once 'include/Webservices/ModuleTypes.php';
> $current_user = CRMEntity::getInstance('Users');
> $current_user->retrieveCurrentUserInfoFromFile(1);
>
> Error:
> Class "Vtiger_Module_Model" not found in
> /home/vtigercrm/data/CRMEntity.php:84
>
> Any hint what Im doing wrong?
>
>
>
> El mar, 12 dic 2023 a las 2:37, Alan Lord (<alanslists at gmail.com>)
> escribió:
>
>> You _should_ create a new user via the Server API if local, or via
>> Webservices (which is basically the Server APIs over REST):
>>
>> https://community.vtiger.com/help/vtigercrm/developers/server-apis.html
>>
>> HTH
>>
>> Al
>>
>> On 12/12/2023 08:19, Alexander Allen wrote:
>> > I´m trying to create a user via api running this script but I get as
>> > error " *Fatal error*: Uncaught Error: Class "Vtiger_Module_Model" not
>> > found in ../modules/Vtiger/handlers/CheckDuplicateHandler.php:35"
>> >
>> > Does some one achieve this before? Im using vtiger 7.5 with php 8.1
>> >
>> > <?php
>> >
>> > require_once 'modules/Users/Users.php';
>> > $user_email='new_user at yourdomain.com
>> > <mailto:new_user at yourdomain.com>';
>> > $role_id_to_assign='H1';
>> > $user = new Users();
>> > $user->column_fields["last_name"] = 'John';
>> > $user->column_fields["user_name"] = 'Mee2';
>> > $user->column_fields["status"] = 'Active';
>> > $user->column_fields["is_admin"] = 'off';
>> > $user->column_fields["user_password"] = $user_password;
>> > $user->column_fields["tz"] = 'Europe/Berlin';
>> > $user->column_fields["holidays"] = 'de,en_uk,fr,it,us,';
>> > $user->column_fields["workdays"] = '0,1,2,3,4,5,6,';
>> > $user->column_fields["weekstart"] = '1';
>> > $user->column_fields["namedays"] = '';
>> > $user->column_fields["currency_id"] = 1;
>> > $user->column_fields["reminder_interval"] = '1 Minute';
>> > $user->column_fields["reminder_next_time"] = date('Y-m-d H:i');
>> > $user->column_fields["date_format"] = 'dd-mm-yyyy';
>> > $user->column_fields["hour_format"] = 'am/pm';
>> > $user->column_fields["start_hour"] = '08:00';
>> > $user->column_fields["end_hour"] = '23:00';
>> > $user->column_fields["imagename"] = '';
>> > $user->column_fields["internal_mailer"] = '1';
>> > $user->column_fields["activity_view"] = 'This Week';
>> > $user->column_fields["lead_view"] = 'Today';
>> > $user->column_fields["email1"] = $user_email;
>> > $user->column_fields["roleid"] = $role_id_to_assign;
>> > $new_user_id = $user->save("Users");
>> >
>> > ?>
>> >
>> > _______________________________________________
>> > http://www.vtiger.com/
>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20231212/5ae3572a/attachment.html>


More information about the vtigercrm-developers mailing list