Hide empty profile fields in profiles
#1
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).


Attached Files
.xml   patches-hide-empty-profile-fields.xml (Size: 1.28 KB / Downloads: 349)
Reply
#2
euantor ~ hiding empty contact details would be a great addition if you ever managed
Weather Lounge - Weather Discussion Forums
Reply
#3
Contact details work slightly differently to profile fields, though it is possible to hide empty ones using the template conditionals plugin.
Reply
#4
Thanks, i will have to have a look at this Big Grin
Weather Lounge - Weather Discussion Forums
Reply
#5
Does it work in custom profile fields in postbit?
New perceptions keep us inspired.
Reply
#6
No. Easiest way to do that would be the template conditionals plugin.
Reply
#7
(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?
New perceptions keep us inspired.
Reply
#8
(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.
Please don't PM me for support. Smile
Reply
#9
Why don't you use Template Conditionals?
Reply
#10
@brad-t for the tutorial? You could do, but I wrote this before I found out about it/started using it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)