I’m new to a lot of this stuff, so hopefully this is easy...
The goal is to have the registered, logged-in user take a survey only ONE time...
So my plan is to have them take the survey (while logged in) and when they hit the submit button, delete their user profile.
This way they can not log back in and retake the survey.
How should I go about doing this (code examples would really help). I’m not sure how to put all of this together, but from what I have seen and done so far it’s an awesome tool.
Thanks!
-
☆ A M B ☆
- 24,524 Posts
The SESSION has all of the information you need (specifically the internalKey), so part of processing the vote (after the vote results have been successfully saved) just delete from the web_users, web_users_attributes and webgroups tables where the userid is the SESSION[’internalKey’].
$modx->db->delete($modx->getFullTableName('web_users'), 'id='.$_SESSION['internalKey']);
repeat for the other two tables. For the web_user_attributes table use the internalKey field; for the webgroups table use the webuser field.
Of course, if the user was never assigned to a web group you can skip that one.
Thanks for the replies. Everyone’s input is much appreciated.
Maybe I should go with just disabling the user instead of deleting them. As long as they can not log in anymore...
Is setting the attributes to "blocked" the easiest way of denying access?
Any thoughts?
-
☆ A M B ☆
- 24,524 Posts
Yes, just update the table, set blocked = 1 where internalKey = $_SESSION[’internalKey’].
I can’t seem to get ’id=’.$_SESSION[’internalKey’]) to work...if I manually enter in the ID, this works fine.
But when I try the ’id=’.$_SESSION[’internalKey’]), nothing happens. What am I doing wrong?
$modx->db->update(’blocked = "1"’, $modx->getFullTableName(’web_user_attributes’), ’id= "8"’);
vs.
$modx->db->update(’blocked = "1"’, $modx->getFullTableName(’web_user_attributes’), ’id=’$_SESSION[’internalKey’]));
Help! Thanks once again.
please have a look onto the quotes, braces and points!
they seem a little bit chaotic ...
maybee this is better (not tested!):
$modx->db->update(’blocked = "1"’, $modx->getFullTableName(’web_user_attributes’), ’id="’.$_SESSION[’internalKey’].’"’);