×

info

Dear guests,
You are currently on the old forum we kept as a knowledge base. You will find the new community forum here
Welcome, Guest
Username: Password: Remember me
Keyword

TOPIC: RSFrom and Acymailing mapping custom field PHP script

RSFrom and Acymailing mapping custom field PHP script 3 years 10 months ago #103830

  • Anonymous user
  • nino59's Avatar
  • Posts: 30
  • Karma: 0
Hi,

I have last RSFrom and Last Acymailing Entreprise.

I created custom field "Dropdown select" list for the field Title= M or Mme or Mlle
I have this same field in RSForm as "Dropdown select" list for the field Title= M or Mme or Mlle

When I test the rsform. user is added in Acymailing list but the dropdown list field is not filled.

I read similar issue:
www.acyba.com/forum/5-acymailing-how-to/...stom-acy-fields.html


I added your solution
foreach($myUser as $field => $val){
if(is_array($val)) $val = implode(',',$val);
$myUser->$field = strip_tags($val);
}

But it didn't work.

User is still added with name and email but no Title.

Could you help me please?
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 10 months ago #103831

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

Please provide us with your custom code so that we will be able to take a look at it and let you know what's the problem ;)
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 10 months ago #103842

  • Anonymous user
  • nino59's Avatar
  • Posts: 30
  • Karma: 0
Here is the php code in RSFORM:
$postData = JRequest::getVar('form');
 
 include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php');
 
 $myUser = new stdClass();
 $myUser->email = strip_tags($postData['Email']); //Please replace email_field by your own field name (the name of the field "email").
 $myUser->name = strip_tags($postData['Nom']); //Please replace name_field by your own field name (the name of the field "name").
 $myUser->title = strip_tags($postData['Title']); //Please replace name_field by your own field name (the name of the field "title").
 $subscriberClass = acymailing_get('class.subscriber');
 
 $subid = $subscriberClass->save($myUser);
 
 
$subscriberClass->sendConf($subid); //we send the confirmation email... only if needed based on the current user status and the option from the Acy configuration page.
 
 $subscribe = array(7); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to lists IDs 3,4 and 5.
 
 $newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
foreach($myUser as $field => $val){
if(is_array($val)) $val = implode(',',$val);
$myUser->$field = strip_tags($val);
}
 $subscriberClass->saveSubscription($subid,$newSubscription);

Here is acymailing custom field screenshot:
prntscr.com/cmosdh

Here is RSFORM custom field screenshot:
prntscr.com/cmosw7

Thanks for your help
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 10 months ago #103850

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

This should be a different behavior as your field is a dropdown.
If you're confortable with PHP then feel free to take a look at the $_REQUEST var and check the format.
If not, feel free to send us an email at This email address is being protected from spambots. You need JavaScript enabled to view it. with a temporary super admin access and all the steps to follow in order to create a new RSForm user.
This way we will take a look at it :)
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105595

  • Anonymous user
  • neil3965's Avatar
  • Posts: 8
  • Karma: 0
What was the outcome of this please?

I have exactly the same problem - a dropdown Title field from an RSForm Pro form is not being inserted in the AcyMailing database, but all other custom fields are added properly.
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105622

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

Could you please let me know what is the custom code you use ?
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105625

  • Anonymous user
  • neil3965's Avatar
  • Posts: 8
  • Karma: 0
Hi there

Script called on form process:
$fullname=$_POST['form']['first_name'] ." ". $_POST['form']['last_name'];

Script called after form has been processed:
$postData = JRequest::getVar('form');
 
include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php');
 
 $myUser = new stdClass();
 $myUser->title = strip_tags($postData['title']);
 $myUser->name = $fullname;
 $myUser->first_name = strip_tags($postData['first_name']);
 $myUser->last_name = strip_tags($postData['last_name']);
 $myUser->email = strip_tags($postData['email']);
 $myUser->dateofbirth = strip_tags($postData['dateofbirth']);
 $myUser->address1 = strip_tags($postData['address1']);
 $myUser->address2 = strip_tags($postData['address2']);
 $myUser->city = strip_tags($postData['city']);
 $myUser->postcode = strip_tags($postData['postcode']);
 $myUser->country = strip_tags($postData['country']);
 $myUser->phone = strip_tags($postData['phone']);
 $myUser->mobile = strip_tags($postData['mobile']);
 $myUser->membership_type = strip_tags($postData['memb_type']);
 $myUser->ballot_by_email = strip_tags($postData['ballot_by_email']);
 $myUser->legal1 = strip_tags($postData['legal1']);
 $myUser->legal2 = strip_tags($postData['legal2']);
 $myUser->proposer = strip_tags($postData['proposer']);
 $myUser->referees = strip_tags($postData['referees']);
 
 $subscriberClass = acymailing_get('class.subscriber');
 
 $subid = $subscriberClass->save($myUser);
 
 $subscribe = array(3); //Specify here the ID of lists to subscribe to, separated by a comma
 
 $newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
 $subscriberClass->saveSubscription($subid,$newSubscription);
Last Edit: 3 years 8 months ago by Anonymous user. Reason: forgot code tags
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105629

  • Tom
  • Tom's Avatar
  • Posts: 4581
  • Karma: 188
Hello,

Why did you put the code in two different places? The variable $fullname you created in the first script is not reachable in the second script.
You should simply use this in your second script (called after form has been processed):
$myUser->name = strip_tags($postData['first_name']).' '.strip_tags($postData['last_name']);
Last Edit: 3 years 8 months ago by Tom.
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105631

  • Anonymous user
  • neil3965's Avatar
  • Posts: 8
  • Karma: 0
The variable $fullname works absolutely fine, thank you.

My problem, as stated in my post, is the same as the oriiginal poster - the value of the dropdown Title field is not being inserted in the AcyMailing database.
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105636

  • Tom
  • Tom's Avatar
  • Posts: 4581
  • Karma: 188
Hello,

I guess he found the solution on his own as I can't find any mail from him regarding this :)
Basically the title is a dropdown and not a text input. So you need to get the value and
You should display the content of the $postData variable to know what is the structure for this field and how you can get it.
$postData = JRequest::getVar('form');
echo '<pre>';
print_r($postData);
echo '</pre>';
exit;
Last Edit: 3 years 8 months ago by Tom.
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105640

  • Anonymous user
  • neil3965's Avatar
  • Posts: 8
  • Karma: 0
Thank you for the tip on using print_r to see the contents of the $_POST data.

By the way, the correct PHP to put in 'Script called after form has been processed' is:
echo '<pre>';
print_r($_POST);
echo '</pre>';
exit;

This reveals that the value from the 'title' dropdown is an array:
Array
(
    [form] => Array
        (
            [title] => Array
                (
                    [0] => Master
                )

            [first_name] => Neil ... etc

Therefore the correct syntax for adding the 'title' value to the database is:
$myUser->title = strip_tags($postData['title'][0]);

Just add [0] after the field name to select the first value of the array. It works now!

Many thanks!
Please log in to post a reply

RSFrom and Acymailing mapping custom field PHP script 3 years 8 months ago #105641

  • Tom
  • Tom's Avatar
  • Posts: 4581
  • Karma: 188
Thanks for sharing your solution!

My script was intended to be used inside the whole script, so having already populated the $postData variable. I updated my previous script to be sure it can be used on its own ;)
Please log in to post a reply
Time to create page: 0.066 seconds
Powered by Kunena Forum