×

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: Subscribe to different lists dependent on rsform checkbox field.

Subscribe to different lists dependent on rsform checkbox field. 3 years 8 months ago #106290

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
Hey Guys,

So i read this www.acyba.com/acymailing/127-acymailing-rsformpro.html but what I want is not here.
I have a small form, with name, email and two different checkbox fields one says "yes i'm a member" which is a condition for the second field that says: "I only want to receive member news."

What I want to happen is the following: when no checkbox is clicked a user is only subscribed to list 1
When "yes i'm a member" is clicked the user is subscribed to list 1 and 2
When "I only want to receive member news" is clicked the user is subscribed to only list 2

My knowledge of scripts is very limited, if someone can modify the code from the documentation to be able to do above I can change the field id's and list id myself I just don't know how to make the script itself...

Any help is much apreciated
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 8 months ago #106294

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
I also found this, only its still missing something since it only takes the value but does not let me take out list 1 of only member news is selected.

www.acyba.com/forum/5-acymailing-how-to/...x-groups.html#106004
Last Edit: 3 years 8 months ago by Anonymous user.
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 8 months ago #106328

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

Please provide me with the code you're currently using and with the result of this code :
echo '<pre>';
print_r($postData);
echo '</pre>';
exit;

Please add this at the bottom of your script. This should break the page and display some information.
Copy/Paste these information here so that I will take a look at it and give you the code you need ;)
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106374

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
Thanks!

This is what I fabricated myself based on what I read in the various sources:
$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_field']); //Please replace email_field by your own field name (the name of the field "email").
 $myUser->name = strip_tags($postData['name_field']); //Please replace name_field by your own field name (the name of the field "name").
 $subscriberClass = acymailing_get('class.subscriber');
 
if(empty($postData['lid']) AND (empty($postdate['ledennieuws']){
 $subscribe = array(3); //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.
} ;
elseif(!empty($postData['lid']) AND (empty($postdate['ledennieuws']){
 $subscribe = array(1,3); //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.
};
else(!empty($postData['lid']) AND (!empty($postdate['ledennieuws']){
 $subscribe = array(1); //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.
};
 
 $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.
 
 $newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
 $subscriberClass->saveSubscription($subid,$newSubscription);

I put this into the Script called after form has been processed field.

When I put your extra code before or after the above nothing happens, when I take out my code and add yours i get a white page with no content, even when i look at the source it's just empty pre tags
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106396

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

If you put only the code Alexandre gave you, it won't work as the $postData variable wouldn't exist.
You can try with this:
$postData = JRequest::getVar('form');
echo '<pre>';
print_r($postData);
echo '</pre>';
exit;
In your code you should not put ";" before your else and elseif. This is probably braking your code and this is why the extra code at the end was not giving you any result. Here is a fixed version of your code that should work better:
$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_field']); //Please replace email_field by your own field name (the name of the field "email").
$myUser->name = strip_tags($postData['name_field']); //Please replace name_field by your own field name (the name of the field "name").
$subscriberClass = acymailing_get('class.subscriber');
 
if(empty($postData['lid']) AND (empty($postdate['ledennieuws']){
	$subscribe = array(3); //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.
} elseif(!empty($postData['lid']) AND (empty($postdate['ledennieuws']){
	$subscribe = array(1,3); //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.
} else(!empty($postData['lid']) AND (!empty($postdate['ledennieuws']){
	$subscribe = array(1); //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.
}
 
$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.

$newSubscription = array();
if(!empty($subscribe)){
	foreach($subscribe as $listId){
		$newList = array();
		$newList['status'] = 1;
		$newSubscription[$listId] = $newList;
	}
}
$subscriberClass->saveSubscription($subid,$newSubscription);
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106403

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
Thanks!

That sort of thing is what i usually get wrong when i try to mess with php myself :P

here is the result from your snippet:
Array
(
    [naam] => christiaan klatte
    [email] => christiaan_klatte@hotmail.com
    [lid] => Array
        (
            [0] => Ja, ik ben lid van de AViN
        )

    [versturen] => 
    [formId] => 5
)

This is without the code for sending it to acy because that didnt work and together they give no result
Last Edit: 3 years 7 months ago by Anonymous user.
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106404

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
for completeness here are the two other possible result:
Array
(
    [naam] => christiaan klatte
    [email] => christiaan_klatte@hotmail.com
    [lid] => Array
        (
            [0] => Ja, ik ben lid van de AViN
        )

    [ledennieuws] => Array
        (
            [0] => Ik wil alleen ledennieuws ontvangen.
        )

    [versturen] => 
    [formId] => 5
)
Array
(
    [naam] => christiaan klatte
    [email] => christiaan_klatte@hotmail.com
    [versturen] => 
    [formId] => 5
)

What I would like to happen is the first result subscribes to list 1 and 2 (previous post)
The second result subscribes to only list 2
The third result subscribes to only list 1
Last Edit: 3 years 7 months ago by Anonymous user.
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106518

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

What's the name of the parameter belonging to your lists ?
I mean, in the first and the second results there are two different parameters : ledennieuws and lid.

Could you please tell me more about these parameters ?
What kind of information belong to them ?
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106582

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
I guess it was a bit vague so I will try.

There are 2 lists, one of them is a Member-list and one is a General-list.
There are also 2 checkboxes Lid and Ledennieuws. Lid means member in dutch and ledennieuws means members-news.
Ledennieuws is dependant on lid so you can not choose ledennieuws without first checking lid, ledennieuws is hidden until lid is checked.

As a visitor there are 3 posibilities:
Option 1: Subscribe to the general newsletter -> No "Lid" or "Ledennieuws" checked
Option 2: Subscribe to the general newsletter AND the member newsletter -> Only "Lid" is checked
Option 3: Subscribe to only the member newsletter -> "Lid" AND "Ledennieuws" are checked

So as a visitor if I only fill in my name and email i get subbed to the general newsletter.
If I check "lid" I get both newsletters.
When I check "lid" a new option appears "ledennieuws" if I check this I only receive the members newsletter.

I hope this helps
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106596

  • Tom
  • Tom's Avatar
  • Posts: 4581
  • Karma: 188
Thanks for the explanation.
Was the code I gave you not working? It seems to fit what you described.
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106755

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
Hi Tom,


Sorry it takes me this long to reply, for some reason i seem to be missing the notifactions when you reply.
Yes, from what I understand from PHP it should do what I need, only for some reason the info does not reach Acymailing.
Last Edit: 3 years 7 months ago by Anonymous user.
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106805

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

I think the best solution for you is to ask for a freelancer or someone who is comfortable with PHP so that he will be able to help you. Or maybe someone on the forum would be glad to give you a helping hand :)
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106910

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
Hi Alexandre,

You are probably right, there is one more thing I thought maybe is the problem, right now the website is in maintenance mode, requiring at least a demo login to view. Could it be that being logged in is what is the problem with the above code?
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106933

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

The maintenance mode shouldn't change anything so I don't think that's the problem with the custom code..
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106946

  • Anonymous user
  • stip's Avatar
  • Posts: 161
  • Karma: 2
This is kind of what I feared, I thought maybe being logged in was somehow an issue since your form submission could then be tied to the demo login user?
Please log in to post a reply

Subscribe to different lists dependent on rsform checkbox field. 3 years 7 months ago #106968

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

There is no reason for this..
You should definitely ask for someone to take a closer look at it and give you some help.

If you want us to spend some time on it we can't do it as custom work for sure.
Feel free to email us at This email address is being protected from spambots. You need JavaScript enabled to view it. if you need us to take a closer look ;)
Please log in to post a reply
Time to create page: 0.144 seconds
Powered by Kunena Forum