AcySMS

hitek6456

New Member
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);
 
I tried this code below but it still doesn't work, can you please help.

$myPhone = '{youth___mobile}';
$myEmail = '{youth___email}';
$myName = '{youth___first_name}';
$myLastname = '{youth___last_name}';
$myBirthdate = '{youth___birthdate}';

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_phone_number = $myPhone;
$myUser->user_email = $myEmail;
$myUser->user_firstname = $MyName;
$myUser->user_lastname = $myLastname;
$myUser->user_birthdate = $myBirthdate;


$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);
 
Is this code in a file, or in the inline PHP box?

What hook are you using (onBeforeProcess, onAfterProcess, etc)?

-- hugh
 
OK, placeholders may not work onAfterProcess.

Try using this instead:

Code:
$myPhone = $formModel->getElementData('youth___mobile');

-- hugh
 
Fixed.

You were trying to user youth___mobile, but your element is actually called youth___phone.

Also youth___birthday not youth___birthdate.

Also PHP variables are case sensitive, and you had $Myname instead of $myName where you assigned it to the new object.

-- hugh
 
Fixed.

You were trying to user youth___mobile, but your element is actually called youth___phone.

Also youth___birthday not youth___birthdate.

Also PHP variables are case sensitive, and you had $Myname instead of $myName where you assigned it to the new object.

-- hugh
Your awesome, Thanks!!!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top