Protecting content for supporters only

I’ve seen this bounce around the forum but haven’t found a solution to hide content and have it available for supporters only.

There is a great plugin that works with amember that does this, here it is:

http://wordpress.org/extend/plugins/hidepost/

It’s perfect for what I’m trying to do, but the trick for me is to get it going for supporters only.

I copied some code from one of my other plugins thats been hacked and came up with this:

if ( function_exists(is_supporter) && !is_supporter() ) {

echo ‘<div class="wrap">’;

echo ‘<div id="message" class="error"><p>This feature is limited to supporters only. Click here to find out how and why to become a supporter.</p></div>’;

echo ‘<h2>’.__(‘Hidepost’:wink:.'</h2>’;

echo ‘</div>’;

return;

}

Not sure if it’s at the right place within the file or if its just completely wrong.

I attached a screenshot as the plugin has various restriction rules already setup for either role managers or admin, etc.

So how would I get this to work for supporters only?

Thanks,

George

  • Aaron
    • Ex Staff

    That’s a fun one. Sounds like it would be simple but it is not for one main reason:

    Supporter status is tied to individual blogs, not users. If a user visits any blog you can not determine if they are a supporter or not because it has nothing to do with the user but a blog. It is designed for limiting features on a blog by blog basis.

    The only way to do it is to check if any of the blogs they are a member of are supporter blogs, which works but is resource intensive and a bit wacky at best, because a supporter blog may have a thousand users, and they would all be "supporters".

    I have created an is_supporter_user() function that will do this and will be part of the next update to the Supporter plugin coming very soon though. I’m sure many will find that very useful!

  • georgef
    • The Incredible Code Injector

    Thanks for that Aaron.

    Ok, I see what you mean. I want to protect the content on my main site so that obviously won’t work.

    Ok, so best bet to wait for the new supporter plugin then.

    Has anyone accomplished some way to protect content in some way?

    Thanks,

    George