Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Premium Content Plugin
I am looking at the PremHide plugin and am looking to make one modification to the plugin that I think would be useful for others as well. Currently the PremHide plugin makes content behind the 'prem' tags only visible to logged in members.
I want to extend that and make it visible to logged in members with premium roles. Here is the code for the PremHide plugin that checks if a user is logged on and grants viewership to contents behind 'prem' tags.
if (($Session->IsValid())) { $pattern = '#\[.?prem\]#si'; $context = preg_replace($pattern, "", $body);
I want to add an && statement that also checks if the current user session has premium roles.
0
Comments
In vanilla you grant access based on permissions and you can assign permissions to roles.
Creating a new permission is easy: simply add a 'RegisterPermissions' entry to your plugin info and you can use that with Gdn::session()->checkPermission to see if the current user has that permission.
Do a full text search for finding examples.
@R_J Thanks! I got it to work as I wanted.
For those reading and still lost, here is how it works:
You give your plugin a placeholder in the roles & permissions section of the dashboard by inserting the following code into your plugin php file:
'RegisterPermissions' => array('Plugins.Premium.View'),
The options are View, Delete, Edit, Notify, etc. (you'll see them in the roles & permission page)
Then you check if the user has the permissions with this bit of code:
(CheckPermission('Plugins.Premium.View'))
which returns a true or false depending if the user has the permissions listed.I have two things now that I want to add to this plugin:
I'll try to figure it out. Once I do, is there a way I can contribute to this plugin?
Modify the regex like this:
'#\[prem\](.*?)\[[\/\\]prem\]#si'
This is how you add a button to the advanced editor:
You will also need to write some javascript to execute the insertion when the button is clicked.
https://github.com/adrianspeyer/VanExtend/tree/master/Plugins/PremHide
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
@Bleistivt Thanks. I'll look into the last bit on execution of the button insertion.
I've just now created a Github. I don't know how to contribute.
https://vanillaforums.org/discussion/26822/a-git-github-primer