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

Core option to hide posts by a generic message for guests?

Betclever

Active member
#1
Hello all,

Is there any option or add-on to hide posts and replace them by a generic message like:

"You need to register to view this post"?

Thanks.
 

Betclever

Active member
#2
I found this post but I don't know how to proceed exactly... Can someone help me a little bit to clarify this post?

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.