13 Posts
9 years ago

Hi Sebloders. I'm hoping I can get a little help/advce.

What I'm trying to do... 

I'm building a site function where users complete an assessment form which assigns them to a 'satisfaction_group' (low=3, moderate=4, high=5) - this I've been able to achieve successfully. 

Now, when the user submits the assessment form, I want to also update the users subscription to an acymailing newsletter list based on the satisfaction_group they're assigned to - low = listid 3, moderate = listid 4, high = listid 5. 

My users are all subscribed to the moderate list on registration, so acymailing knows they exist with id values setup, etc. Users will be subscribed to one mailing list only. Just fyi, acymailing creates a subscriber id (subid) matched to each joomla userid. 

I thought I would be able to do this with a 42 field, using the following code in 'PrepareStore'... 

// assign to satisfaction group based on their score 

$total = $config['post']['total_satisfaction'];

if ($total >= 3 && $total <=9) $value = 3;

if ($total >= 10 && $total <=16) $value = 4;

if ($total >= 17 && $total <=21) $value = 5; 

//this $value gets saved in the db in a seperate table along with the all the scores etc. - this works all good

$userid = $config['post']['satisfaction_user_id']; // this is obtained using a 'live' value - perhaps it's better to get it from user->id?? 

// now query the database to get the subscriber_id for the logged in user from acymailing 

$db = JFactory::getDbo(); 

$query1 = $db->getQuery(true); 





$subid = $db->loadResult();

//then update the acymailing subscription to reflect the satisfaction group 

$sql = "UPDATE `#__acymailing_listsub` SET listid=".$value." WHERE subid=".$subid."; 



The code is not throwing any errors on save, the $value and other scores is saved to its table, but the acymailing listid is not being updated. I'm a php and seblod novice, and an sql noob, so I'm probably going about this the wrong way, so any help/suggestions would be appreciated. 

Thanks in advance


Get a Book for SEBLOD
13 Posts
9 years ago
Level 1

Looks like I am able to answer my own question...

$query1->where('id='.$userid); should read $query1->where('userid='.$userid);

and the UPDATE statement needed the quotes closed.

And now is working! Onward!

Thanks friends

1283 Posts
8 years ago
Level 2


Get a VIP membership