×

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: RsFormPro and Acy - get list ID's from two checkbox groups?

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105455

  • Anonymous user
  • celius's Avatar
  • Posts: 41
  • Karma: 0
Hi,

I'v setup a from with two checkbox groups.

I now want to want to get the ID's I've assigned as values for these checkbox items in the two lists into one, so I can subscripe to all the lists needed.

I'm using "Script called after form has been processed".
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105482

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

In your script, you need to get the content of the checkbox, check all values to get only the check ones.
Then you put these values in the $subscribe array.

If you have issues doing this, please send us the URL of the page where we can see the form and tell us which fields are the checkbox groups you want to check.
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105579

  • Anonymous user
  • celius's Avatar
  • Posts: 41
  • Karma: 0
Hi again,

The form is at drammenhundepark.no/kontakt/undersokelse

Check "Ja" in the first page, then you see the list "Hvorfor besøker du Drammen Hundepark?(*)" which are added with values matching ID of AcyMailinglist.

If you check the one named "Være med på hundekurs" you get a new list on page three, which also has values matching ID of AcyMailing lists.

I'm not sure on how to get the values from these two fields, combine them into $subscribe array..
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105599

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

In the script you can use to subscribe to AcyMailing, you get all data submitted in the form in the $postData variable.
You can display the content of the variable to see how to get the fields data:
echo '<pre>';
print_r($postData);
echo '</pre>';
exit;
You should make a loop on each list field (spm3 and spm5) to get the checked ones and add them in the $subscribe variable.
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105664

  • Anonymous user
  • celius's Avatar
  • Posts: 41
  • Karma: 0
Hi again, and thanks for that. I can confirm at least that the desired data is there. But I'm not sure on how to create this loop and place the ID's into $subscribe variable. Could you please assist with that?
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105692

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

Please provide us with the result of the previous code given by Thomas so that we will be able to help you ;)
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105734

  • Anonymous user
  • celius's Avatar
  • Posts: 41
  • Karma: 0
$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['epost']); //Please replace email_field by your own field name (the name of the field "email").
 $myUser->frekvens = strip_tags($postData['spm2']); // Skriver inn hvor ofte de er på besøk for å treffe bedre
 $myUser->notvisited = strip_tags($postData['spm4']); // Årsak til at de ikke har besøkt DHP
 $myUser->fjernes = strip_tags($postData['spm6']); // Ønsker de å fjernes fra nyhetsbrev? Kun for de som ikke har besøkt DHP før..

 $myUser->listene = strip_tags($postData['spm3']); // Holdes the ID's of some of the lists that I want to assign to
 $myUser->listene = strip_tags($postData['spm5']); // Holdes more ID's to assign, but this can also be none.

 $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(15); //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();

 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;

 }
 $subscriberClass->saveSubscription($subid,$newSubscription);

There are two lines, where I do not know how to get all the ID's and correctly set it up so that $subscribe has it like it needs to:
$myUser->listene = strip_tags($postData['spm3']); // Holdes the ID's of some of the lists that I want to assign to
 $myUser->listene = strip_tags($postData['spm5']); // Holdes more ID's to assign, but this can also be none.
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105742

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

We don't need your code but the result of the code given by Thomas (what is displayed when you use this :
echo '<pre>';
print_r($postData);
echo '</pre>';
exit;

This way we will be able to see how the data is set and how to get the value you need easily ;)
Last Edit: 3 years 8 months ago by Alexandre.
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105746

  • Anonymous user
  • celius's Avatar
  • Posts: 41
  • Karma: 0
Oh, sorry.. *palm to forhead*
Array
(
    [epost] => kenneth@webist.no
    [spm1] => Ja
    [spm2] => Nesten hver måned
    [spm3] => Array
        (
            [0] => 2
            [1] => 4
            [2] => 3
        )

    [spm5] => Array
        (
            [0] => 18
            [1] => 19
        )

    [spm7] => 
    [spm6] => Nei
    [send] => 
    [formId] => 9
)
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105772

  • Tom
  • Tom's Avatar
  • Posts: 4581
  • Karma: 188
According to the data you get, you don't need to make a loop. You can use this:
$subscribe = array_merge($postData['spm3'], $postData['spm5']);
Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #105785

  • Anonymous user
  • celius's Avatar
  • Posts: 41
  • Karma: 0
Thank you! That surely was a sexy solution to it!!

Please log in to post a reply

RsFormPro and Acy - get list ID's from two checkbox groups? 3 years 8 months ago #106004

  • Anonymous user
  • celius's Avatar
  • Posts: 41
  • Karma: 0
Original question:
There is an issue I just discovered.

If I only select one or more from the first field ($postData, and nothing from the next - the user isn't added to any lists.

In spm3 I have a conditional field, so that when one of these items is checked it shows spm5. So each time the item that shows spm5 isn't checked nothing is subscribed to.

Any ideas?

I just solved it. Changed to:
$subscribe = array_merge((array)$postData['spm3'], (array)$postData['spm5']);
Last Edit: 3 years 8 months ago by Anonymous user.
Please log in to post a reply
Time to create page: 0.071 seconds
Powered by Kunena Forum