PDA

View Full Version : Custom user.php with specific custom profile fields...


AFemaleProdigy
11-23-2011, 08:26 PM
Hello,

I am creating multiple custom user.php files to make creation of specific user types easier. I have entirely too many custom profile fields that are specific to user types to keep them all in one single user.php. I need some assistance figuring out the proper code for just a few things.

Rather than use the existing lines that generate ALL of the custom profile field options, I want to display only specific custom profile field options. For example, in user.php there are lines like this:

print_select_row($vbphrase['language'] , 'user[languageid]', array('0' => $vbphrase['use_forum_default']) + fetch_language_titles_array('', 0), $user['languageid']);I need to write a line similar to that which loads a specific user profile field and it's available input/select/radio options. I am just not sure how to write it, how to call the field, and how to load the options for the field.

I was trying to guess at it and came up with this, but it doesn't work right. I need it to load the array of options specific to that field... NOT a vbphrase:

print_select_row($vbphrase['field11_title'], 'user[field11]', array(0 => $vbphrase['venue_type_a'], 2 => $vbphrase['venue_type_b'], 1 => $vbphrase['venue_type_c']), $user['field11']);Should I use this instead: print_chooser_row

Any suggestions? Thanks!

--------------- Added 24 Nov 2011 at 10:50 ---------------

Anyone have any ideas? I just need to know the bit of code to load a specific profile field and its selectable options in user.php.

Thanks!

AFemaleProdigy
11-26-2011, 06:33 PM
Help?

kh99
11-28-2011, 03:04 AM
Sorry, but I'm not sure what you want to do. Are you asking how to use the print_select_row() function?

AFemaleProdigy
11-28-2011, 03:17 AM
Sorry if my explanation wasn't clear. In admincp, you use user.php to create new users and enter the details for that user's custom profile fields. By default, user.php lists ALL custom profile field options that have been created in the database. I have created a secondary modified user-venue.php file, and want to display only certain custom profile fields, not all of them like the default does.

So, I need to remove the default code that generates ALL of the custom profile field options in my modified user-venue.php. I located it and removed it. Now, I need to replace that with the code that will generate specific profile fields. I don't know what code to use to make that happen.

My goal is to have a secondary user.php file that will make my life easier by only showing me the custom profile fields I want, relative to the type of usergroup I am putting someone in.

Does that make more sense? Thanks for replying, by the way.

kh99
11-28-2011, 03:39 AM
OK, I think I get that. Assuming I do understand, it seems like the easiest thing to do would be to leave the existing code but modify the SQL to get the fields you want, or else leave the SQL to get all the fields but modify the loop to "continue;" if the field is not one that you want to display.

AFemaleProdigy
11-28-2011, 03:50 AM
Well, I wouldn't know how to go about doing that. I still want the original user.php file to function as normal. Would what you are suggesting affect the original as well as the new modified version, user-venue.php?

kh99
11-28-2011, 04:04 AM
It would only affect your new file if you don't modify the code in user.php. I assume you removed this code?:

$profilefields = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "profilefield AS profilefield
LEFT JOIN " . TABLE_PREFIX . "profilefieldcategory AS profilefieldcategory ON
(profilefield.profilefieldcategoryid = profilefieldcategory.profilefieldcategoryid)
ORDER BY profilefield.form, profilefieldcategory.displayorder, profilefield.displayorder
");
while ($profilefield = $db->fetch_array($profilefields))
{
if ($profilefield['form'] != $currentform)
{
print_description_row(construct_phrase($vbphrase['fields_from_form_x'], $forms["$profilefield[form]"]), false, 2, 'optiontitle');
$currentform = $profilefield['form'];
}
print_profilefield_row('userfield', $profilefield, $userfield, false);
construct_hidden_code('userfield[field' . $profilefield['profilefieldid'] . '_set]', 1);
}


so if you have a list of profilefieldids you want to display in your modified file, you could probably change the query part to be something like (line in red added):

$profilefields = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "profilefield AS profilefield
LEFT JOIN " . TABLE_PREFIX . "profilefieldcategory AS profilefieldcategory ON
(profilefield.profilefieldcategoryid = profilefieldcategory.profilefieldcategoryid)
WHERE profilefieldid IN(1, 2, 3, 4)
ORDER BY profilefield.form, profilefieldcategory.displayorder, profilefield.displayorder
");

AFemaleProdigy
11-28-2011, 04:24 AM
I tried what you suggested and it worked! Hurray!!! Thanks so much! I was trying to do it a harder way, of course! Lol!

So for anyone trying to do this... forget everything I was trying and do what kh99 said in the last post.