XF 1.0 How to create a new field in the member profile

AndreaMarucci

Well-known member
In the VB4 forum, before the switch, I had one custom field in the member profile page that every user used to put in the real name.

I'm searching for something to let users put some extra contact info in their profiles (like telephone number, email, real name and so on) but I would like that these info are only visible to a specific usergroup (registered members that have payed the annual quota). For now it suffice to have a field for the real name but if I could use the same system to put in also the phone number or the email, should be good.

I think that this could be done modifying one template but I really don't know how and where...

Anyone can suggest how I can do that?
 
Profile fields don't have group permissions.

A template edit would work even though it's not an ideal solution to maintain privacy of those fields. Where do you want those fields to be conditionally displayed?
 
Admin CP -> Appearance -> Templates -> member_view

Find the userBlurb and add the red code:

Rich (BB code):
				<p class="userBlurb">
					{xen:helper userBlurb, $user}
					<xen:if is="{xen:helper ismemberof, $visitor, 5}">
						<div style="font-size: 11px;">
							Name: {$user.customFields.name} - Telephone: {$user.customFields.phone} - Email: {$user.email}
						</div>
					</xen:if>
					<xen:if is="{$canCleanSpam}"><a href="{xen:link spam-cleaner, $user}" class="deleteSpam OverlayTrigger">{xen:phrase spam_cleaner}</a></xen:if>
				</p>

You need to fill in the blue pieces which are the privileged groupid and the field_ids for the custom fields for name and phone number.
 
Thanks Jake, two questions

1 - If I would need more than one usergroup, which is the correct syntax. I would need groups ID 12,3,4
2 - Where the user is supposed to fill the custom fields name and telephone?

I've pasted the code and the email appears but the other two are blank spaces.

Thanks...
 
If I would need more than one usergroup, which is the correct syntax. I would need groups ID 12,3,4

There is short syntax for checking multiple primary groups:

Rich (BB code):
				<p class="userBlurb">
					{xen:helper userBlurb, $user}
					<xen:if is="in_array({$visitor.user_group_id}, array(12,3,4))">
						<div style="font-size: 11px;">
							Name: {$user.customFields.name} - Telephone: {$user.customFields.phone} - Email: {$user.email}
						</div>
					</xen:if>
					<xen:if is="{$canCleanSpam}"><a href="{xen:link spam-cleaner, $user}" class="deleteSpam OverlayTrigger">{xen:phrase spam_cleaner}</a></xen:if>
				</p>

But to check both primary and secondary you have to use the long form:

Rich (BB code):
				<p class="userBlurb">
					{xen:helper userBlurb, $user}
					<xen:if is="{xen:helper ismemberof, $visitor, 12} OR {xen:helper ismemberof, $visitor, 3} OR {xen:helper ismemberof, $visitor, 4}">
						<div style="font-size: 11px;">
							Name: {$user.customFields.name} - Telephone: {$user.customFields.phone} - Email: {$user.email}
						</div>
					</xen:if>
					<xen:if is="{$canCleanSpam}"><a href="{xen:link spam-cleaner, $user}" class="deleteSpam OverlayTrigger">{xen:phrase spam_cleaner}</a></xen:if>
				</p>

I've to add that I'm using XF 1.0.4 and not 1.1

You need to create custom profile fields for the name and phone number. Custom profile fields are only in version 1.1.
 
I did that with a line edit using paul importer. I pull up the content of that custom field into the About me ...
add this code change the #3 with your field number

if (isset($user['field3']))
{
$import['about'] .= $this->_convertToUtf8($user['field3']) . "\n\n";
}
$import['about'] = trim($import['about']);

Before:

Code:
        switch ($user['usergroupid'])

I did this way back...
so please try this in a test forum & back-up your database.
 
Top Bottom