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ā€?

You know, for the time being, I will just update the Patreon page link display name to ā€œDoubleToasted.com (or) DoubleToastedā€™s Patreonā€¦ā€ and that should do it!

Example:
This content is available exclusively to members of DoubleToasted.com (or) DoubleToastedā€™s Patreon at $X or more.

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ā€™.

Yes, it does. But I needed to tweak the Custom Patreon Page Name in the plugin settings to accomplish what I needed.

Before:
To view this content, you must be a member of DoubleToastedā€™s Patreon at $3 or more

After:
To view this content, you must be a member of DoubleToasted.com or Patreon at $3 or more

Reads just fine now!

1 Like