Giving access to non-admin roles

Anyone in the Administrators role can view any locked post. Is it possible to configure the plugin so that users in the Author, Editor, or Contributor roles can view locked posts?

Currently there isnt a way to easily do that via options. You could do it through code modifications.

I started adding some code to my own plugin to accomplish this. I looked through the source and I saw the “ptrn/bypass_filtering” filter. Is this what I should be hooking into? Do you have any samples of how to use this?

My attempt so far is this (with pseudocode):

function patreon_bypass_filtering( $filter ) 
{
    if ( !$filter )
    {
        if ( <User is Author> )
        {
            return true;
        }
    }

    return $filter;
}
add_filter( "ptrn/bypass_filtering", "patreon_bypass_filtering", 10, 1 );
1 Like

Thats a good way of doing it…

Hi, We’ve been trying to accomplish the same thing. So glad we stumbled on your post. Did this hook eventually work? Also was this injected through some php snippet plugin?

Thanks!

Hello,

I created a WordPress Plugin to allow access to a specific role for our needs. I used the information at this site for creating the plugin and then added the following code to the PHP file I created in the steps provided in the link above:

<?php
/*
 * Plugin Name: my-over-rule-patreon
 * Description:      Allow anyone with the Role of Staff to access Patreon content.
 * Version:           1.0
 * Author:            Karl S
*/
function patreon_bypass_filtering( $filter ) 
{
    if ( !$filter )
    {
		$user = wp_get_current_user();
		if ( in_array( 'staff', (array) $user->roles ) ) {
			//The user has the "staff" role
			return true;
        	}
    }

    return $filter;
}
add_filter( 'ptrn/bypass_filtering', 'patreon_bypass_filtering', 10, 1 );
?>

Change ‘staff’ to whatever role you wish to provide access and save the file. In your Plugings you should see your plugin listed and you will need to Activate such.

Thank you to @worker11811 for the pseudocode, and stackexchange for getting the current user’s roles.

Hopefully this helps others. It would be GREAT if the Patreon team could add the ability to allow specific site defined Roles to override/ignore the block. Until such time, I hope this helps others looking to do the same.

Karl S

1 Like

That’s indeed a good use of the in-built filters. Kudos.

This worked like a charm! Thanks so much. I used it to allow paid website subscribers (Subscriber role) access to the Patreon posts.

Question though… The content is correctly unlocked for website subscribers, but it still shows this line of text at the bottom of the posts: “This content is available exclusively to members of DoubleToasted’s Patreon at $0 or more.”

This will be a potentially confusing statement for website subscribers who are not Patrons. Thoughts?

1 Like

What tier is the content locked for?

Thanks for your reply. My client hasn’t finished setting up his Patreon account yet. We are still in the testing phase. I understand the “$0” mention has to do with the tier, but not concerned with that at this time. I was just wondering how, if at all possible, we could disable all of this text from displaying to the ‘Subscriber’ user role on his website. In other words, if the content is no longer gated, don’t display any text at all. Hope that makes sense!

If the content is public, it should not display any text. But if the content is gated, it displays an informational text which tells the patron how and why s/he qualifies for the content. This avoids many confusions and support situations to the creator and plugin support alike.

I understand. I notice if I’m logged in as Administrator, it displays this text “This content is for Patrons only, it’s not locked for you because you are an Administrator”. Any way to display that for subscribers but say “…because you are a Subscriber”?

It already does that - when a patron logs in, it gives a message in line with ‘This content is available for patrons of X from $ or more’.