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

Hide thread replies from guests

Discussion in 'XenForo Questions and Support' started by bubbl3, Mar 21, 2013.

  1. bubbl3

    bubbl3 Active Member

    Anyone knows a way to do this in a simple way?
     
  2. cclaerhout

    cclaerhout Well-Known Member

    Here's one possible unfinished solution:

    Edit the template: thread_view
    Search:
    HTML:
                <xen:include template="post" />
    
    Replace with:
    HTML:
                <xen:if is="{$firstPost.post_id} == {$post.post_id}">
                    <xen:include template="post" />
                </xen:if>
    
    You just need to complete the conditional with usergroups id and, if needed, with forums id.
     
    bubbl3 likes this.
  3. bubbl3

    bubbl3 Active Member

    Thanks for the suggestion :) I ended up doing this:

    Code:
                    <xen:if is="!{$post.isFirst} && !{$visitor.user_id}">
                    <xen:else />
                    <xen:include template="post" />
                    </xen:if>
    I will have to also hide page navigation, but it works great.
     
    XboxAR likes this.
  4. cclaerhout

    cclaerhout Well-Known Member

    If you want more flexibility, you can read this:

    The visitor object has an element called "permissions". Inside this element, we can find all the permissions groups.
    So to access the permission group "Forum Permissions" (id: forum), here is the code:

    >PHP:
    PHP:
    $visitor XenForo_Visitor::getInstance();
    $forumPerms $visitor['permissions']['forum'];
    >XenForo templates:
    HTML:
    {$visitor.permissions.forum}
    

    We are going to add a new element to the permission group "Forum Permissions".
    Go to: Administration => Development => Permission Definitions
    Click on button "Create New Permission"
    >Permission ID: sedo_canSeefirstPostOnly
    (sedo is just a prefix, use yours)
    > Title: Can only see first post of a thread
    > Permission Group: Forum Permissions
    > Permission Type: Flag
    > Interface Group: Forum Permissions
    > Display Order: 999
    (as you want)
    > Addon: if you want to integrate this permission inside an addon

    To access this new permission:
    >PHP:
    PHP:
    $visitor XenForo_Visitor::getInstance();
    $forumPerms $visitor['permissions']['forum']['sedo_canSeefirstPostOnly'];
    >XenForo templates:
    HTML:
    {$visitor.permissions.forum.sedo_canSeefirstPostOnly}
    
    Now to configure which usergroup should be applied this "permission" (which is here more a restriction than a permission)
    Go to: Administration => Users => Group Permissions
    Select your Usergroup and configure the new "permission"


    So now edit the template thread_view (you can use TMS if you want)

    Search:
    HTML:
                    <xen:include template="post" />
    
    Replace with:
    HTML:
                    <xen:if is="{$visitor.permissions.forum.sedo_canSeefirstPostOnly}">
                        <xen:if is="{$firstPost.post_id} == {$post.post_id}">
                            <xen:include template="post" />
                            <xen:comment>You can add a custom message here with a phrase or a new template (use the same command than above</xen:comment>
                        </xen:if>
                    <xen:else />
                        <xen:include template="post" />
                    </xen:if>
    
    Now if you want to configure this permissions by forums, I can't really help you (except with using another conditional) because that's something I still don't understand with the XenForo Permissions system. I mean, in theory if you set the permission "canSeefirstPostOnly" on a usergroup, you should select a node and revoke this permission to allow users to see others posts... but it doesn't work, at least on my boards.

    If someone has an explanation on this, I will more than happy to hear it.
     
    luutruong and bubbl3 like this.
  5. bubbl3

    bubbl3 Active Member

    Yeah a permission would be the best way to do this, hope someone will explain/fix it.
     
    cclaerhout likes this.
  6. cclaerhout

    cclaerhout Well-Known Member

    But in your case, since you seem to only need to set permissions by usergroups, the above solution will work without any problem for you.
     
  7. bubbl3

    bubbl3 Active Member

    Thanks, I will give it a try :)
     
  8. rotpar

    rotpar Member

    Does it work? Is it possible to show a message to guests right after the first post like: "if you want to read more, please register"
     
  9. Flexin

    Flexin Active Member

    I thought bout something like this but it always drove me nuts on forums. There is a couple that worked at getting me to join. I was on one in the last month that showed the first 5 posts. I like this because it allows you to see the type of answers people are getting on the forum and or get a small feel for the forum. And it kinda gives you just enough to get interested in a thread and then cuts you off. Might work at getting some to join.

    Is that possible?

    James
     
  10. the100yen

    the100yen Member

    Another request for this function
     
  11. SatGuyScott

    SatGuyScott Active Member

    Would be great if this worked so that if the guest is using an ad blocker they will not be shown the replies...
     

Share This Page