How do I display ads only to certain users?

Jaxel

Well-known member
Lets say I have a premium membership upgrade path with usergroup 5. If someone purchases premium membership, they will automatically join secondary usergroup 5. Inside of a TEMPLATE, how would I check to see if a user is part of this group? Basically I want to do something like:

Code:
<xen:if is="!is_member($visitor, '5')">
AD CODE
</xen:if>
 
Have you tried adding the ! right after the first " as shown below?

HTML:
<xen:if is="!{xen:helper ismemberof, $visitor, 5}">
	<!-- content -->
</xen:if>


<xen:if is="{$post.position} == 0 AND !{$visitor.user_id}">

is what I currently have. That should only show the google ads (what is the conditional) to visitors, correct?

I want to say if they arent a member of my paid for group (No Ads that is part of the pay for update system) show the ads.
 
in the message template (at the very bottom) for your style, try this:

HTML:
<xen:if is="!{$post.position} AND !{$visitor.user_id}">

    <xen:if is="!{$message.conversation_id}">
code for Ad here....  Remove $message.conversation_id IF statement if you want ads shown after 1st message of a PC as well.

    </xen:if>

</xen:if>
 
in the message template, at the very bottom) for your style, try this:

HTML:
<xen:if is="!{$post.position} AND !{$visitor.user_id}">

    <xen:if is="!{$message.conversation_id}">
code for Ad here....  Remove $message.conversation_id IF statement if you want ads shown after 1st message of a PC as well.


    </xen:if>

</xen:if>

First, thanks for your help!

Second, what if I want to show to everyone BUT the admin group and those that paid to upgrade? Groups 3 and 20
 
First, thanks for your help!

Second, what if I want to show to everyone BUT the admin group and those that paid to upgrade? Groups 3 and 20


If you know the group id's and they are their primary group ids, then this will work for you (it's the simplest for your case):

HTML:
<xen:if is="!{$post.position} AND !{$visitor.is_admin} AND {$visitor.user_group_id} != '20'">

    <xen:if is="!{$message.conversation_id}">
code for Ad here....  Remove $message.conversation_id IF statement if you want ads shown after 1st message of a PC as well.


    </xen:if>

</xen:if>
 
If you know the group id's and they are their primary group ids, then this will work for you (it's the simplest for your case):

HTML:
<xen:if is="!{$post.position} AND !{$visitor.is_admin} AND {$visitor.user_group_id} != '20'">

    <xen:if is="!{$message.conversation_id}">
code for Ad here....  Remove $message.conversation_id IF statement if you want ads shown after 1st message of a PC as well.


    </xen:if>

</xen:if>


Does that group have to be a primary group? is there a way to do it for additional groups?
 
Does that group have to be a primary group? is there a way to do it for additional groups?

Yip, for addition groups that is where the newly added helper will come in. I haven't played with the ismemberof helper, but this should work (I just tested this quickly):

HTML:
<xen:if is="!{$post.position} AND !{$visitor.is_admin} AND !{xen:helper ismemberof, $visitor, 20}">

    <xen:if is="!{$message.conversation_id}">
code for Ad here....  Remove $message.conversation_id IF statement if you want ads shown after 1st message of a PC as well.


    </xen:if>

</xen:if>
 
Yip, for addition groups that is where the newly added helper will come in. I haven't played with the ismemberof helper, but this should work (I just tested this quickly):

HTML:
<xen:if is="!{$post.position} AND !{$visitor.is_admin} AND !{xen:helper ismemberof, $visitor, 20}">

    <xen:if is="!{$message.conversation_id}">
code for Ad here....  Remove $message.conversation_id IF statement if you want ads shown after 1st message of a PC as well.


    </xen:if>

</xen:if>


Perfecta! Now just figure how to have google ads post after the 1st post on a page and im set! haha
 
Perfecta! Now just figure how to have google ads post after the 1st post on a page and im set! haha

!{post.position} already does that. Or if you want to display ads after the first post on every page then use this.

Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$visitor.is_admin} AND !{xen:helper ismemberof, $visitor, 20}">

    <xen:if is="!{$message.conversation_id}">
code for Ad here....  Remove $message.conversation_id IF statement if you want ads shown after 1st message of a PC as well.


    </xen:if>

</xen:if>
 
Top Bottom