XF 2.1 How to block usergroup from viewing threads until they upgrade?

Anomandaris

Well-known member
Users are required to purchase an upgrade to use my forum. Guests are allowed to view 10 pages before they are required to register. Then after they register they are pushed to purchase an upgrade. But for some reason, they can still view the entire forum at this stage.

Here's how it currently works when someone signs up:
  1. Register
  2. Confirm email
  3. <-------
  4. Account upgrade is purchased
  5. Now they can do whatever they want
Basically after step 1 or 2, they should be unable to view any threads.

These are my permissions:
1622847308015.png
1622847325588.png

But they can still view the entire forum, when I analyze the permissions for the users it says these are all set to NO.

But they can still view all threads.

I setup a "usergroup promotion" which adds a secondary usergroup with these same permissions if they have not purchased an upgrade.

The same thing occurs.

What am I doing wrong? How do I make a specific usergroup unable to view threads?
 
Solution
This is nothing to do with Monetize specifically. Core XF functionality is that if a user's status is not "Valid", their permissions come from the Unregistered / Unconfirmed group. It states this under the "User state" field in your screenshot.

1623062763857.png

This is the reason it's not applying the permissions you've configured for the Registered group - it's not using that usergroup to apply permissions, it's using the Unregistered / Unconfirmed group. This is core XF behaviour - when a user is in any state other than "Valid", whether that state is from core XF or an addon, they are treated as a guest.

The problem is then that your Unregistered / Unconfirmed usergroup is configured to allow browsing of the forum, thus newly...
This is nothing to do with Monetize specifically. Core XF functionality is that if a user's status is not "Valid", their permissions come from the Unregistered / Unconfirmed group. It states this under the "User state" field in your screenshot.

1623062763857.png

This is the reason it's not applying the permissions you've configured for the Registered group - it's not using that usergroup to apply permissions, it's using the Unregistered / Unconfirmed group. This is core XF behaviour - when a user is in any state other than "Valid", whether that state is from core XF or an addon, they are treated as a guest.

The problem is then that your Unregistered / Unconfirmed usergroup is configured to allow browsing of the forum, thus newly registered users can do so because their account status is not yet "Valid" and it's using those same permissions. It is non-typical to allow guests to have more permissions than newly registered users, which is why it's not working as you are expecting.

Monetize is indeed putting the user into the "Awaiting user upgrade purchase" state, however you would be having the exact same problem if you simply set them to require email activation as their state would be "Awaiting email confirmation" - they would not be "Valid" until they verified their email address, and would also be using the Unregistered / Unconfirmed usergroup permissions until they did so. The purpose of forcing a user to purchase an upgrade is that that is what then makes their account "Valid" as opposed to verifying their email address.

The long and the short of it is that, as far as I can see, allowing guests to view forums but not allowing newly registered users to do so until they upgrade is not physically possible within XF's permissions system, whether you're using Monetize or not, as until they do whatever it is they need to do for their account to be "Valid", they are treated as guests, and you are allowing guests to browse the forum. The permissions system isn't designed to do what you're trying to do. You would need an addon to change what permissions are applied when a user is not "Valid".

I don't really think this setup makes a lot of sense - the only incentive to registering is to either see content you can't see as a guest, or to be able to post - but if you block browsing the forums until people upgrade, what's to stop them just logging out to browse? They're only going to pay for something they can't already do some other way, why would they pay to read threads they can already read as a guest? I know you limit guests to 10 threads but you can get around that easily by opening a fresh incognito browsing window. I think you're trying to incentivise the wrong thing with your paywall.
 
Last edited:
Solution
Even with all addons disabled, this is still occurring. Can someone please give me some suggestions on how to debug this?

Even with permissions set to NEVER or NO on both usergroups, they can still view everything. I'm at a total loss.

Thank you in advance
 
Ahhhh I have found where the issue occurs.

When the userstate is "Awaiting user upgrade purchase", they can view the entire website still
1622955682156.png

The second you flip this over to Valid, they are unable to view threads, as I intended.

They are forced into this "Awaiting user upgrade purchase" state via ThemeHouse Monetize when using the option "Require user upgrade on registration". I believe that only can happen when using this option in that addon.

I'm not sure if it's possible for stock XF to even put people in this state, to be honest.

I have contacted their support.

Oddly tho, this issue occurs even with all plugins disabled, as long as they're in this state, the usergroup permissions don't seem to have any effect.
 
Last edited:
extremely ghetto solution:

HTML:
<xf:if is=

"$template == 'thread_view'

&& $xf.visitor.user_id

&& $xf.visitor.secondary_group_ids == ''

&& $xf.visitor.user_state == 'email_confirm'
 
|| $xf.visitor.user_state == 'thmonetize_upgrade'

 
">
   
// redirect to /account/upgrades/

</xf:if>
 
Top Bottom