Selecting Roles to Unlock Content

When published content is gated for viewing by Patreon level, it is also locked for all Wordpress roles except administrators. As an administrator, I see the following message:

This content is for Patrons only, it’s not locked for you because you are an Administrator

I would like my site editors to be able to see locked content, but do not want to elevate them all to admins. How can I expand the list of roles which are able to bypass the paywall to see posted content? Thanks for the help!

In the same manner which comments can be filtered, you can hook to the ptrn/lock_or_not filter, check for the role of a user and then turn off locking by modifying the $lock_or_not value.

I will keep trying until that advice makes sense! :joy:

In the meantime, here is what I found that worked:

  • I found a capability that aligned with the roles I wanted to bypass the paywall: edit_others_posts
  • I went through patreon_frontend.php and replaced every instance of current_user_can('manage_options') with current_user_can('edit_others_posts'). That ended up being on lines 984, 1145, 1506, 1549
  • I then made the same replacement in patreon_wordpress.php on line 1645

Those changes did what I wanted, and allowed my editors to see content published behind the paywall. I’m capturing the details because I’m sure I will have to reassert these changes if/when the plugin is updated. Or until I figure out how to hook into the filter as you described.

Thank you again!

Going the filter/hook route is always better and its the recommended way for modifying WP and plugin behavior in WordPress in general. So in the long run, it would be much better to take that route.

I’ll risk reviving this thread to say that I still haven’t fully grasped what you meant by hooking into the filter, but I now recognize the importance of working within the recommended confines of WordPress. The theme I was using issued an update months ago. I dragged my feet on implementing it for fear that it would overwrite my custom code changes I described here, which of course it ended up doing.

It also changed the behavior of some of the CSS changes I had made. I have restored the appearance of my site and even enhanced it, this time by using configurations instead of hacking. I should be more resistant to future updates making unwanted changes. All thanks to your suggestions here, @codebard. Thank you!

1 Like

Np. hooks and filters allow you to take advantage the strengths of WP without having to do extensive coding.

Also, if you are modifying a theme, do create a child theme and use it instead. This way your mods wont be overwritten if the parent theme is updated.