I created a form called Youth and added a form plug in to transfer the the info using PHP API. It looks like all is set up correctly but it won't send the receiver into the group I selected. Any help on this would be greatly appreciated. Code used is below.
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acysms'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
echo 'This code can not work without the AcySMS Component';
return false;
}
$myUser = new stdClass();
$myUser->user_firstname = strip_tags($postData['youth___first_name']); //Please replace firstname_field by your own field name (the name of the field "firstname").
$myUser->user_lastname = strip_tags($postData['youth___last_name']); //Please replace lastname_field by your own field name (the name of the field "lastname").
$myUser->user_phone_number = strip_tags($postData['youth___phone']); //Please replace phone_number_field by your own field name (the name of the field "phone_number").
$myUser->user_birthdate = strip_tags($postData['youth___birthday']); //Please replace birthdate_field by your own field name (the name of the field "birthdate").
$myUser->user_email = strip_tags($postData['youth___email']); //Please replace email_field by your own field name (the name of the field "email").
$phoneHelper = ACYSMS::get('helper.phone');
$validPhone = $phoneHelper->getValidNum($myUser->user_phone_number);
if(!$validPhone){
echo 'Invalid Phone Number';
return false;
}
$userClass = ACYSMS::get('class.user');
$userId = $userClass->save($myUser);
$subscribe = array(4); //Specify here the ID of your groups separated by a comma, in this example the user will be subscribed to groups IDs 3,4 and 5.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $groupId){
$newList = array();
$newList['status'] = 1;
$newSubscription[$groupId] = $newList;
}
}
$userClass->saveSubscription($userId, $newSubscription);
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acysms'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
echo 'This code can not work without the AcySMS Component';
return false;
}
$myUser = new stdClass();
$myUser->user_firstname = strip_tags($postData['youth___first_name']); //Please replace firstname_field by your own field name (the name of the field "firstname").
$myUser->user_lastname = strip_tags($postData['youth___last_name']); //Please replace lastname_field by your own field name (the name of the field "lastname").
$myUser->user_phone_number = strip_tags($postData['youth___phone']); //Please replace phone_number_field by your own field name (the name of the field "phone_number").
$myUser->user_birthdate = strip_tags($postData['youth___birthday']); //Please replace birthdate_field by your own field name (the name of the field "birthdate").
$myUser->user_email = strip_tags($postData['youth___email']); //Please replace email_field by your own field name (the name of the field "email").
$phoneHelper = ACYSMS::get('helper.phone');
$validPhone = $phoneHelper->getValidNum($myUser->user_phone_number);
if(!$validPhone){
echo 'Invalid Phone Number';
return false;
}
$userClass = ACYSMS::get('class.user');
$userId = $userClass->save($myUser);
$subscribe = array(4); //Specify here the ID of your groups separated by a comma, in this example the user will be subscribed to groups IDs 3,4 and 5.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $groupId){
$newList = array();
$newList['status'] = 1;
$newSubscription[$groupId] = $newList;
}
}
$userClass->saveSubscription($userId, $newSubscription);