XF 2.2 Can I customise the 'you do not have permission' message?

Hilary

Member
I'd like my free members to upgrade to access paid-for resources. But at the moment, if they speculatively click on a link to one of these to see what it's all about, they see,

Oops! We ran into some problems.​


You do not have permission to view this page or perform this action.

Dead end. It would be nice to replace that with some directions explaining how they can access it. Is there a feature or an add-on for that?
 

Hilary

Member
Very good idea, thank you! I've jumped in and done that, and yes, it is possible to add links.

(Any way of making it specific to the forum, so I could send people directly to buy the thing they're interested in?)
 
Last edited:

Alan_SP

Active member
For that, you can use notices system, and if users aren't in usergroup that have access, you can show them notice if they're in specific forum. Each notice can have many different criteria.
 

Tracy Perry

Well-known member
If you are using upgrades to add them to a group, then yes, Notices should work fine.

You would use the User is not a member of option and then also the specific page/node desired.
 

Hilary

Member
Alas, tried this and the notice doesn't appear. Notices in general will appear on these 'do not have access' pages, but as soon as I introduce a 'page is within nodes' criterion, the notice disappears. I think the 'forbidden' page must not count as being 'within' the node, despite the url.

:(

Ah well. The edited phrase is a big improvement.
 

Nicolas FR

Well-known member
Hello @Hilary,
You can try this code in your error template (replace all the content with this code) :
HTML:
<xf:title>{{ phrase('oops_we_ran_into_some_problems') }}</xf:title>

<div class="blockMessage">
    <xf:if is="$error">
        <xf:if is="$xf.visitor.isMemberOf(2) and $template !== 'xfrm_resource_view'">
            To access to this resource page you have to... bla bla bla...
        <xf:else />
            {$error|raw}
        </xf:if>
    <xf:else />
        <ul>
        <xf:foreach loop="$errors" value="$error">
            <li>{$error|raw}</li>
        </xf:foreach>
        </ul>
    </xf:if>
</div>

Change the usergroup ID in $xf.visitor.isMemberOf(2) to match your need
Change the "To access to this resource..." phrase to match your need too.
 

Nicolas FR

Well-known member
@Hilary you spoke about resource that's why i set the conditon like this <xf:if is="$xf.visitor.isMemberOf(2) and $template !== 'xfrm_resource_view'"> but if your "resources" are threads or you want to display the specific error message in specific forums you can change the template condition.
 

Hilary

Member
They're specific forums - and there are two membership levels, so the conditions get a bit complicated: if you're trying to access forum x and you're not part of a or b, show this; if you're trying to access forum y and you're not part of b, show this. Could you help with that?

(And should I be messing with this given that I'd just be copying and pasting your code without fully understanding it?)

(I can probably answer that one myself...)
 

Alan_SP

Active member
They're specific forums - and there are two membership levels, so the conditions get a bit complicated: if you're trying to access forum x and you're not part of a or b, show this; if you're trying to access forum y and you're not part of b, show this.
I guess that notices won't work, as after you try to access forum and you don't have access to it, you're redirected to error message, which don't know from where you come.

I'm not sure if there's a way to check from where users come (ie which forum), so they can get correct error messages.

EDIT:
Thinking about it a bit more, you might try to set up your permissions differently. Your paid forums aren't visible at all, unless you have paid to access them. I see you link them through navbar, but I can't see forums at all.

If you would make forums (ie nodes) visible, but content visible only with subscription, then notices will work.node setup.gif

Of course, first take notice how did you set it up previously, so you can return in case it wouldn't give you desired results.
 
Last edited:

Hilary

Member
It’s probably doable. Can you write here all the different scenario with real usergroup and forums ID ? I can try if you want.
That would be very kind, but I'll try Alan's suggestion of changing permissions first.
I guess that notices won't work, as after you try to access forum and you don't have access to it, you're redirected to error message, which don't know from where you come.
The funny thing is that when the error message is displayed, the url in the browser address bar is still that of the forum you can't access. So you'd think it would 'know where you are', as it were.
I'm not sure if there's a way to check from where users come (ie which forum), so they can get correct error messages.

EDIT:
Thinking about it a bit more, you might try to set up your permissions differently. Your paid forums aren't visible at all, unless you have paid to access them. I see you link them through navbar, but I can't see forums at all.

If you would make forums (ie nodes) visible, but content visible only with subscription, then notices will work.

Of course, first take notice how did you set it up previously, so you can return in case it wouldn't give you desired results.
I will definitely try this next, thank you!
 

Alan_SP

Active member
And now that those forums are visible, interested people are more likely to purchase subscription when they see that there's some private content.

Only thing is, when I try to access wiki, I see same error message, I think you should be able to define notice just for wiki, using Page criteria tab targeting wiki pages. Not sure which wiki you use, as I don't have access to your wiki pages, I just see that it's wiki add-on.
 

Hilary

Member
I use VaultWiki, and it has a different permissions system so I have no idea how to replicate the 'can view forum, can't view content' permission that makes the notice appear. I'll need to ask their support. I'm going to update first - wish me luck.
 

Hilary

Member
I did, and he was (as always). What worked for me (just in case any other VaultWiki users find their way here in future): set permissions so the user can view the wiki index page (but nothing else), and then create a notice with usergroup criteria to catch those who don't have access, and Page criteria > Page information > Selected navigation tab is: vw. Now logged-in, non-paying members will see the notice on the Wiki index page, and get the notice along with the 'no access' error message if they try to go further in.

Success. Many thanks for your help!
 
Top