MyBB Community Forums

Full Version: Display default value on unfilled textbox profile fields in member.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
EDIT: ok, i realize i wasn't really clear at first, so here's an example of what i mean with pictures.

on member.php, i have a div that contains some custom profile fields, because i want them in a specific place & order (rather than all of them being in "additional info").

here's what i want it to look like:
[Image: capture2.PNG]
as you can see, this user has not filled out the "aliases" and "sexuality" sections.

here's what it looks like right now:
[Image: Capture.PNG]
because there's no value available, the dd containers simply collapse.

i've placed these profile fields using this code:
<dt class="trow1">Full Name:</dt> (the actual name of the userfield, which i've entered manually)
<dd class="trow2">{$userfields['fid5']}</dd> (the value; if none is available I.E. user hasn't filled it out yet, there is nothing to hold the cell's height up, and it collapses)

hi, i couldn't find any info on this for the past hour or so of searching, so new thread!

i am making a member profile layout that places specific custom profile fields in specific areas outside of "additional fields", so i have to call them with the "userfields" tag. this means that the rule that makes them invisible when a user hasn't filled them out does not apply, and i end up with empty broken cells in my DL, where the field name i've written out in plain text shows up but its accompanying cell with the actual value collapses, because there's no value available.

i could just hide all the fields that aren't filled out or add a default size for the DL cells, but in order to preserve my design, i'd prefer to add placeholder text to all custom profile fields that aren't filled out--like "No information", etc.--so the DL simply does not collapse, and i'm left with a neat acknowledgement that the user simply hasn't provided that information, but that it has a place. something like what happens when the date-of-birth option isn't filled out, or is hidden, and it shows up as "not specified", rather than simply hiding the field altogether.

unfortunately everything i've found for this is either outdated or doesn't apply to the member.php or textbox/textarea fields, and although i'm comfortable editing core files i'm not quite experienced enough to do an adaption that large on my own! i would also prefer to avoid adding large plugins for this one thing, if possible.

any ideas on how to do this? i've seen it for every mybb forum i've used in the past but have no idea how it's achieved, it seems so simple... thanks!

I don't know if I understand what you want clearly, but I'll try to answer what I think you want.

If you go to Admin Control Panel > Templates & Style (Tab) > Templates > Your Theme > User Control Panel Templates > usercp_profile_profilefields_text

You could edit it to add the placeholder you want, for example:
<input type="text" name="profile_fields[$field]" class="textbox" size="{$profilefield['length']}"{$maxlength} value="{$value}" placeholder="Fill this please" />

And in usercp_profile_profilefields_textarea you could change it to:
<textarea name="profile_fields[$field]" rows="6" cols="30" style="width: 95%" placeholder="Come on... fill this">{$value}</textarea>

And for the select fileds, in usercp_profile_profilefields_select_option you have to add one line:
<option value="" disabled selected hidden>Please Choose...</option>
<option value="{$val}"{$sel}>{$val}</option>

Hope it helps
EDIT: ah, actually, that wasn't what i wanted. it's a nice feature though LOL
EDIT 2: i modified the original post with more specific info on what i need help with! i want a response to show up even if a user has not manually edited a profile field yet. so, like this:

- say i am looking at a user's profile, on member.php.

- in this scenario, the user in question has not filled out any part of their profile yet.

- because i don't want the profile fields to show up in only the "additional information" section on the member.php page, which is where they appear by default, i've typed in this to call the "full name" field, which is field # 5:
Full Name: {$userfields['fid5']}

- because it hasn't been filled out by the user yet, it show shows up like this:

Full Name:           

- i want it to show up like this:

Full Name: N/A

that is what i want.

now I undesrtand, sorry for the previous confusion.

Maybe if in your DB, in the PREFIX_userfields table, you'll have now a column fid5. If you replace all the NULL values with the "No information" desired and change the default value of the column from NULL to "No information", maybe it'll work as you want.

Same to the other field.

IMPORTANT: remeber to make a backup of the DB before making any changes.