Author Topic: How to create vm user by API function  (Read 138 times)

mhs_pro

  • Beginner
  • *
  • Posts: 5
  • A beginner
How to create vm user by API function
« on: January 20, 2019, 18:28:30 pm »
Hi
I want create user with API function in vm 3

I checked how a user was register
in public_html/administrator/component/com_virtuemart/models/user.php there is a function named store(&$data).
Code: [Select]
public function store(&$data){

$message = '';
==> vRequest::vmCheckToken('Invalid Token, while trying to save user');

if(empty($data)){
vmError('Developer notice, no data to store for user');
return false;
}
This function checks vRequest::vmCheckToken

How can I fill out the vRequest?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3626
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: How to create vm user by API function
« Reply #1 on: January 21, 2019, 09:58:24 am »
You need to call 2 times the server to do something secured
First time using JSession::getFormToken(); to get the form field name and you have to set it to 1
Using CURL you need to  send POST datas.
Some explain to get token here : https://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms
You can perhaps set this directly in the server POST datas using Joomla or virtuemart input function.