Hello, On my signup page, i have added a addition field called 'date'. Which is working fine. But, I am looking for a way to update that additional 'date' field in the database, from the add/renew subscription form. I looked at the 'amembers_members' table and see that the additional fields are stored in the 'data' column as name/value pairs. How would i update this information? Is there a snippet of code I could add to a php page (member.php or signup.php), or to a certain function, that will include the additional field info when the subscription gets renewed? Any information would be greatly appreciated!
Here is how additional field can be set: PHP: $user = $db->get_user($member_id);$user[data][fieldname] = "value";$db->update_user($member_id, $member); If you want to set this field when user purchase subscription, use finish_waiting_payment hook: http://manual.amember.com/Using_site.inc.php_and_hooks#finish_waiting_payment.28.24payment_id.29
Hi Alexander, Thanks for that snippet of code! Would I add that to the do_renew function to update the data during a subscription renewal? Much appreciated...thank you!
Ok... have the 'fwp' function in the site.inc.php file, and the function is running because i see the printed output, but how do i pass the value of the form field from the member_add_renew.html template to line below? $user[data][fieldname] = "value";
It should be passed from renewal form and should be stored in member's profile? It will be updated when user will renew subscription and there will be only one value per user, is this correct? Sorry not sure I understood how this can be used, so want to confirm. may be you need separate field for each payment user complete?
hi alexander, i could not get the $user[data][date] to update when using the site.inc.php file. so i placed your snippet of code in the do_renew() function in member.php and now it updates the database along with the membership renewal. I know updating member.php is bad practice due to updating reasons, but i couldnt get the finish_waiting_payment hook to work in site.inc.php. the function ran but the additional date field was not updated. basically, i have a membership that lasts 24 hours, and when you sign up, you have to pick a date for the membership, the date is an additional field. when you renew that membership, you need to pick a new date, so i needed to update the data.date field in the database. which i have working right now, but not in the best way. I do thank you for your help! I also have another question that pertains to this, but let me know if i should start a new thread for it. Here goes... When you sign up for a 24 hour membership, you need to pick a date. I have a jquery date picker to fill in the input field. I can disable dates in the date picker with an array of dates. So what I need to do is this: select all members that have an active 24 hour membership and grab the additional field called date (data.date), and put those dates into an array. from there i can push that array into the jquery date picker to disable the dates that are already taken. here is a link for visual reference if you don't mind taking a look... http://renderfeed.com/amember/signup1_day.php?price_group=12 i hope this made some sort of sense, and once again, thanks for your help!
You can use this code in order to select dates for all active memberships. PHP: $q = $db->query("select * from amember_members where status=1"); $dates = array();while($res = mysql_fetch_assoc($q)){ $data = unserialize($res[data]); $dates[$data[date]]=1;}return array_keys($dates);
Hi Alexander, Thanks for that handy snippet of code! I have yet to try to work it in... I need to pull the dates array into member.html and signup.html templates. Would i put this code in the site.inc.php and use the smarty code to grab the array value?
Define function in site.inc.php: PHP: function get_dates(){global $db; $q = $db->query("select * from amember_members where status=1"); $dates = array();while($res = mysql_fetch_assoc($q)){ $data = unserialize($res[data]); $dates[$data[date]]=1;}return array_keys($dates); } Then use it in smarty template: PHP: {php}$dates = get_dates();$this->assign("dates", $dates);{/php} Then in template you can use {$dates} array as regular smarty array.
Hi Alexander, The snippet code returns an array of dates, correct? Am I able to grab this array and send the results to a page outside of amember? I have a signup form with a datepicker on it and want to use that array of dates to disable days in the datepicker. Is that possible? Thanks in advance!
Sure, possible. If you have php page, include amember config to access $db->query function. Then add this code: PHP: function get_dates(){global $db; $q = $db->query("select * from amember_members where status=1"); $dates = array();while($res = mysql_fetch_assoc($q)){ $data = unserialize($res[data]); $dates[$data[date]]=1;}return array_keys($dates); } $dates = get_dates();