• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Show "follow" to guests

Luke B

Active member
#1
Hello all,

I would like to show "follow" in the user profile pages as well as the user card to guests. When they click it, it will obviously take them to the "you must be a member..."page.

How would I achieve this?

Thank you
 

Jake Bunce

XenForo moderator
Staff member
#2
Admin CP -> Appearance -> Templates -> member_card

Add the red code:

Code:
		<div class="userLinks">
		<xen:hook name="member_card_links">
			<a href="{xen:link members, $user}">{xen:phrase profile_page}</a>
			<xen:if is="{$visitor.user_id} AND {$user.user_id} != {$visitor.user_id}">
				<xen:if is="{$canStartConversation}"><a href="{xen:link conversations/add, '', 'to={$user.username}'}">{xen:phrase start_conversation}</a></xen:if>
				<xen:follow user="$user" class="Tooltip" />
				<xen:if is="{xen:helper isIgnored, $user.user_id}"><a href="{xen:link members/unignore, $user}" class="FollowLink">{xen:phrase unignore}</a><xen:elseif is="{$canIgnore}" /><a href="{xen:link members/ignore, $user}" class="FollowLink">{xen:phrase ignore}</a></xen:if>
			<xen:elseif is="!{$visitor.user_id}" />
				<a href="{xen:link members/follow, $user}">{xen:phrase follow}</a>
			</xen:if>
		</xen:hook>
		</div>
Admin CP -> Appearance -> Templates -> member_view

Add the red code:

Code:
	<div class="main">

		<div class="section primaryUserBlock">
			<div class="mainText secondaryContent">
				<div class="followBlock">
					<ul>
					<xen:if is="{$visitor.user_id}">
						<xen:follow user="$user" title="" tag="li" />
					<xen:else />
						<li><a href="{xen:link members/follow, $user}">{xen:phrase follow}</a></li>
					</xen:if>
						<xen:if is="{xen:helper isIgnored, $user.user_id}">
							<li><a href="{xen:link members/unignore, $user}" class="FollowLink">{xen:phrase unignore}</a></li>
						<xen:elseif is="{$canIgnore}" />
							<li><a href="{xen:link members/ignore, $user}" class="FollowLink">{xen:phrase ignore}</a></li>
						</xen:if>
						<xen:if is="{$canWarn}">
							<li><a href="{xen:link members/warn, $user}">{xen:phrase warn}</a></li>
						</xen:if>
					</ul>
 

Jake Bunce

XenForo moderator
Staff member
#5
The profile one worked great but the member card one did not. I'm wondering if its because I'm using Xen 1.01 and the template is different?
Sure enough. The code is different in 1.0. Use this in member_card to make it like 1.1:

Code:
		<div class="userLinks">
		<xen:hook name="member_card_links">
			<a href="{xen:link members, $user}">{xen:phrase profile_page}</a>
			<xen:if is="{$visitor.user_id} AND {$user.user_id} != {$visitor.user_id}">
				<xen:if is="{$canStartConversation}"><a href="{xen:link conversations/add, '', 'to={$user.username}'}">{xen:phrase start_conversation}</a></xen:if>
				<xen:follow user="$user" class="Tooltip" />
				<xen:if is="{$canCleanSpam}"><a href="{xen:link spam-cleaner, $user}" class="deleteSpam OverlayTrigger">{xen:phrase spam}</a></xen:if>
			<xen:elseif is="!{$visitor.user_id}" />
				<a href="{xen:link members/follow, $user}">{xen:phrase follow}</a>
			</xen:if>
		</xen:hook>
		</div>
 

Luke B

Active member
#6
Hm, it didn't work
I also included some code to show the "message" link as well. That is working but is it messing the "follow" up somehow? Here is what I have:
Code:
                <div class="userLinks">
        <xen:hook name="member_card_links">
            <a href="{xen:link members, $user}">{xen:phrase profile_page}</a>
            <xen:if is="{$user.user_id} != {$visitor.user_id}">
                <a href="{xen:link conversations/add, '', 'to={$user.username}'}">{xen:phrase start_conversation}</a>
                <xen:follow user="$user" class="Tooltip" />
                <xen:if is="{$canCleanSpam}"><a href="{xen:link spam-cleaner, $user}" class="deleteSpam OverlayTrigger">{xen:phrase spam}</a></xen:if>            
                        </xen:if>
        </xen:hook>
        </div>
 

Jake Bunce

XenForo moderator
Staff member
#7
With the way the condition is structured, you can add more "guest" links in the red area. This is how you would add a PM link as well as a follow link:

Code:
		<div class="userLinks">
		<xen:hook name="member_card_links">
			<a href="{xen:link members, $user}">{xen:phrase profile_page}</a>
			<xen:if is="{$visitor.user_id} AND {$user.user_id} != {$visitor.user_id}">
				<xen:if is="{$canStartConversation}"><a href="{xen:link conversations/add, '', 'to={$user.username}'}">{xen:phrase start_conversation}</a></xen:if>
				<xen:follow user="$user" class="Tooltip" />
				<xen:if is="{$canCleanSpam}"><a href="{xen:link spam-cleaner, $user}" class="deleteSpam OverlayTrigger">{xen:phrase spam}</a></xen:if>
			<xen:elseif is="!{$visitor.user_id}" />
				<a href="{xen:link conversations/add, '', 'to={$user.username}'}">{xen:phrase start_conversation}</a>
				<a href="{xen:link members/follow, $user}">{xen:phrase follow}</a>
			</xen:if>
		</xen:hook>
		</div>