foxhound |
|
---|---|
I am trying to create a new plugin which adds additional fields to a user profile. I have gotten it so far that when I edit the user profile the fields are there and actually contain the data I insert to the DB upon plugin install. But I can for the life of me not figure out how to set the plugin up so that if the field value is changed it actually saves this new data when the user presses "submit". I have created a php for the hooks to "do" when the user updates the profile:
Thanks in advance! Added 4 hours later: So here is the edit part of the plugin: if (!defined('SED_CODE')) { die('Wrong URL.'); } $userid = sed_import('id','G','INT'); $sub_sql = sed_sql_query("SELECT user_subscr_end_date, user_subscr_date_stamp, user_subscriber_status FROM $db_users WHERE user_id='$userid'"); if (sed_sql_numrows($sub_sql) > 0) { $sub = sed_sql_fetcharray($sub_sql); $sub_end = $sub['user_subscr_end_date']; $sub_stamp = $sub['user_subscr_date_stamp']; $sub_status = $sub['user_subscriber_status']; $sub_stamp = strtotime($sub_end); } $t->assign(array( "USERS_EDIT_SUBSCRIPDATE" => "<input type=\"text\" class=\"text\" name=\"subscr_end_date\" value=\"".htmlspecialchars($sub['user_subscr_end_date'])."\" size=\"8\" maxlength=\"10\" />", "USERS_EDIT_SUBSCRIPSTATUS" => "<input type=\"text\" class=\"text\" name=\"subscriber_status\" value=\"".htmlspecialchars($sub['user_subscriber_status'])."\" size=\"1\" maxlength=\"1\" />" ));
And here is the update.done part of the plugin: defined('SED_CODE') or die('Wrong URL'); $userid = sed_import('id','G','INT'); $sub_sql_u2 = sed_sql_query("UPDATE $db_users SET user_subscr_end_date='".sed_sql_prep($sub_end)."', user_subscr_date_stamp='".sed_sql_prep($sub_stamp)."', user_subscriber_status='".sed_sql_prep($sub_status)."', user_auth='' WHERE user_id=$userid"); Now, I have tried about a few million different sql queries trying to perform the update and everything fails. My DB values are never updated when I change them in the user edit page. Added 8 hours later: I tried a few dozen other different values for " <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
|
Отредактировано: foxhound (15.12.2015 08:03, 9 лет назад) |
Macik |
|
---|---|
First of all, lets figures out what Cotonti version you had use? is it Genoa?
p.s. Without seeing error logs I can not guess why your queries working wrong. But you can enable debug mode (in config.php) and use `FOOTER_DEVMODE` tag in the footer.tpl to figure out whats going on. https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
foxhound |
|
---|---|
Wow, thank you very much Macik. That is really some very helpfull info :) Added 1 hour later: Sigh, I still cant get it to work. I have created the fields through the extra fields for users. The fields are in my DB, if I change their value (manually directly in the DB) in my profile I can see the changed values. Added 2 hours later: Got it! <img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
|
|
Отредактировано: foxhound (16.12.2015 17:17, 9 лет назад) |
Macik |
|
---|---|
#41239 foxhound: I'm not shure that it should work in Genoa as Extra field utility not fully functional in that branch.
In common way `FOOTER_DEVMODE` should display full sql queries list with certain SQL code and it's timing. If you don't see it on any page check: Another prehistoric way to debug is to add log line to your code to save info to logfile. You can save raw SQL query text than use some SQL client to run this query and seeing results. But best way to deeper inspect you application — is to install some modern IDE and setup Debugger. Than you can see internals step-by-step.
Great.
You are welcome. https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |