MyBB Community Forums

Full Version: Hide empty profile fields in profiles
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ever looked at a MyBB user's profile and wondered why on earth empty profile fields are displayed? I know I have. That's why I decided to stop empty profile fields from being displayed on my forum and in this guide I'll show you how to do the same.

To achieve this, we'll be making a core file edit. I therefore advise the use of frostschutz's amazing Patches plugin and I've also included an attached patch file.

The file we'll be editing is member.php and we'll be editing around line 1774, which is this:

		eval("\$customfields .= \"".$templates->get("member_profile_customfields_field")."\";");

All we have to do is change it to the following simple code:

		if ($customfieldval != '') {
			eval("\$customfields .= \"".$templates->get("member_profile_customfields_field")."\";");
		}


Simple. I wish I could do it quite so easily for the contact details (well, I have on my own forum, but it takes a slight bit more effort).
euantor ~ hiding empty contact details would be a great addition if you ever managed
Contact details work slightly differently to profile fields, though it is possible to hide empty ones using the template conditionals plugin.
Thanks, i will have to have a look at this Big Grin
Does it work in custom profile fields in postbit?
No. Easiest way to do that would be the template conditionals plugin.
(2013-03-07, 08:44 PM)Euan T. Wrote: [ -> ]No. Easiest way to do that would be the template conditionals plugin.

I installed the PHP in Templates Plugin by Zinga Burga and added this line:
<?php if (!empty($post['fid1'])) {<p>Location: {$post['fid1']}</p>} ?>
Unfortunately it doesn't work. What should I do?
(2013-03-07, 10:16 PM)Adriano Wrote: [ -> ]I installed the PHP in Templates Plugin by Zinga Burga and added this line:
<?php if (!empty($post['fid1'])) {<p>Location: {$post['fid1']}</p>} ?>
Unfortunately it doesn't work. What should I do?

<?php
if(!empty($post['fid1']))
{
echo "<p>Location: " . $post['fid1'] . "</p>";
}
?>

Should work.
Why don't you use Template Conditionals?
@brad-t for the tutorial? You could do, but I wrote this before I found out about it/started using it.