Hello,
i test a script to add in Acysms a user who accepts to receive information by SMS.
Here is the code below:
// on teste si l'utilisateur a donné son accord pour l'utilisation de son numéro de téléphone
if(strcasecmp($postData['Accord tel'],"OUI")==0){
$myUserSMS = new stdClass();
$myUserSMS->user_firstname = strip_tags($postData['RSEProName']); // Nom du champ nom RSEvent
$myUserSMS->user_lastname = strip_tags($postData['Prenom']);
$myUserSMS->user_phone_number = strip_tags($postData['Mobile']);
$myUserSMS->user_email = strip_tags($postData['{RSEProEmail}']); // Nom du champ email RSEvent
$myUserSMS->user_birthdate = strip_tags($postData['Naissance']['d']."/".$postData['Naissance']['m']."/".$postData['Naissance']['y']);
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acysms'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
echo 'Ce code ne fonctionne pas sans le composant AcySMS';
return false;
}
$phoneHelper = ACYSMS::get('helper.phone');
$validPhone = $phoneHelper->getValidNum($myUserSMS->user_phone_number);
if(!$validPhone){
echo 'Numéro de téléphone invalide';
return false;
}
$userClass = ACYSMS::get('class.user');
$userId = $userClass->save($myUserSMS);
$subscribe = array(3); // on spécifie l'id du groupe SMS dans AcySMS (il peut y avoir plusieurs groupes séparés par une virgule)
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $groupId){
$newList = array();
$newList['status'] = 1;
$newSubscription[$groupId] = $newList;
}
}
$userClass->saveSubscription($userId, $newSubscription);
}
At the submission of the form I have no error but the user is not registered in AcySMS. I do not have a new entry.
I have controlled the user's custom fields and I have:
- user_firstname,
- user_lastname,
- user_phone_number,
- user_email,
- user_birthdate.
in the back office of AcySMS.
By enabling the Joomla debugging functions I have no errors.
I tried with and without the condition of acceptance "Accord tel" but it's the same.
Thank you in advance.