MyBB Community Forums

Full Version: Add values from custom profile fields
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
These 4 custom profile fields are drop-down options with # values. These show on the Member Profile.  Would it be possible to also add up the #s the user selected from each field to get a total? I am needing a code I can put onto the Member profile page so it can show "Total: [whatever the total is]"

{$userfields['fid1']}
{$userfields['fid2']}
{$userfields['fid3']}
{$userfields['fid4']}


Example:

User selects the following:

field 1 = 1
field 2 = 1
field 3 = 5
field 4 = 3

Total: 10
Bump. Any help with this?
Use the Template Conditionals plugins :

http://mybbhacks.zingaburga.com/showthread.php?tid=464

<?=my_number_format($userfields['fid1'] + $userfields['fid2'])?>

Edit: Otherwise, you will need a plugin or the Hooks plugin (use the member_profile_end hook) :
https://github.com/frostschutz/MyBB-Hooks
I have installed the plugin and activated and still not working. Here is the string I'm using in the member_profile template.

<?=my_number_format($userfields['fid5'] + $userfields['fid6'] + $userfields['fid7'] + $userfields['fid8'] + $userfields['fid39'] + $userfields['fid40'] + $userfields['fid41'] + $userfields['fid42'] + $userfields['fid43'] + $userfields['fid44'])?>
Hi, it does work for me in my test board.
Are your profile fields drop-down (select box) ? or is it one where the member must type in a #? I don't know if that would make a difference. Mine are select-box (with options like 1, 2, 3 etc). I'm not sure what I'm doing wrong. I have the plugin activated and I dropped the code into the member_profile template.
I did test again, and it works for me with multiple field types (select, radio, and text).

Does the following work ?
<?=my_number_format(10 + 15)?>

If it doesn't, then there is something wrong.
Ah, no that one doesn't work either.
You should try in a fresh install, because these just do work for me using the plugin I did mention above.
That worked. Thank you so much for the help!

EDIT: 

Another question on this, it appears that if the user hasn't yet selected values for those profile fields, it breaks the page / won't load. Is there a way to prevent this from happening?