I'm having a problem with the user_from field which I've customized a little. All of my users will be from the US, so rather than recording their country I'd like to have user_from record their home state.
First, I've modified user_dataform.html to include a select box with all the states. I didn't want to have both an input box and a select box like the default user_dataform.html has for user_from, I just want a simple select box with the state. To do that I modified bb_func_regusr.php and bb_func_editprf.php and added a new variable which calls makeValuedDropDown, in a way similar to how it works with user_sorttopics. When someone registers they can select their home state via the select box and it records the info correctly in the user_from field in the users table.
So far so good.
The problem comes when the user wants to view or update their preferences. The preferences page does not show the state they've selected (it shows the first entry in the select box) even though the user_from field has a value... the SELECTED switch in the select box is not getting set. It seems to work fine for the other fields with select boxes(user_sorttopics, user_viewemail).
My new variable in bb_func_editprf.php and bb_func_regusr.php is defined like this: $fromstateDown=makeValuedDropDown(array( 'AL'=>'Alabama', 'AK'=>'Alaska', ... 'WY'=>'Wyoming'),'from');
I think I've tracked the problem to the makeValuedDropDown function in bb_functions.php. It's checking $GLOBALS[selectName] which is not being set, so it sets $curVal to nothing ('') which is the problem. How can I ensure that $GLOBALS['user_from'] gets set with the value that's in the users table before calling this function?
You can see this behavior for yourself here: http://www.pawinetalk.com/talk
(I also want to capture the user's home County (for those of you not familiar with the US, that's a region within the state but larger than the City) and have created a custom field for this, and am seeing identical behavior...it captures the information inputted and populates the table, but does not display it when you go to Preferences.)
I have the feeling that it's something small/stupid but I've been trying all sorts of things the last 48 hours with no luck.
Thanks for any help! Mark |