Jump to content
DevFuse Forums

Hide Custom Profile Fields


deadmouse

Recommended Posts

How would I go about hiding custom profile fields based on a certain value.

 

So I have a field which says if they have admin on a gaming server. If the field for either Server 1 or Server 2 = Yes then I want it to be displayed but if the fields are both blank then they arent displayed at all.

Link to comment
Share on other sites

  • Management

As far as I can see if a custom field doesn't have a value it shouldn't show in the topic or profile views. Is this a dropdown custom field you have setup? If so what's the value for empty, or do you just have Server 1 and 2 as options?

Link to comment
Share on other sites

  • Management

Might not be able to do it through a template edit, it looks like it loads the full text for displaying the custom field rather then the field id and value.

 

I haven't tested this much but try this edit.

 

Open ips_kernal/classCustomFields.php

 

Find: (around line 650)

if( in_array( trim( $value[0] ), $curr_values ) )

 

Add ABOVE:

		    if( !$value[0] )
	    {
		    continue;
	    }

 

Save ips_kernal/classCustomFields.php. This should now skip any fields with an empty value.

Link to comment
Share on other sites

I not only want to cut out the empty field but if both fields are empty I want to cut that whole section out.

 

This is the code I have so far but have been having issues getting it to work.

 

The custom field groups reference is "server_admin" and the members groups that I want to display the group are 4, 11 and 13.

 

<if test="$group = 'server_admin'">
<if test="IPSMember::isInGroup( $this->memberData, array( 4,11,13 ) )">
	<div class='general_box clearfix' id='custom_fields_{$group}'>
		<h3 class='bar'>{$member['custom_field_groups'][ $group ]}</h3>

		<ul class='ipsList_data clearfix'>
			<foreach loop="pcfieldsOtherLoopCheckInner:$member['custom_fields'][ $group ] as $key => $value">
				<li>{$value}</li>
			</foreach>
		</ul>
	</div>
</if>
<else />
<div class='general_box clearfix' id='custom_fields_{$group}'>
	<h3 class='bar'>{$member['custom_field_groups'][ $group ]}</h3>

	<ul class='ipsList_data clearfix'>
		<foreach loop="pcfieldsOtherLoopCheckInner:$member['custom_fields'][ $group ] as $key => $value">
			<li>{$value}</li>
		</foreach>
	</ul>
</div>
</if>

 

I'm guessing this isn't working becasue of the first if statement but I can't work it out.

Edited by deadmouse
Link to comment
Share on other sites

Well I added the double == but it still isn't working :(

 

*edit*

 

After some testing it seems this isn't working correctly

 

IPSMember::isInGroup( $this->memberData, array( 4,11,13 ) )

 

No clue how to fix it tho lol.

Edited by deadmouse
Link to comment
Share on other sites

  • Management

Well the isInGroup function should support either the member_id or an array like you have, so don't see any problem there. Just to confirm you want to show it to the member viewing the page or the members custom fields your displaying?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...