ViewLevel plugin
-
I’ve made a plugin that lets you restrict the visibility of posts by userlevel (I guess I had the same idea as Skippy!) Check it out here:
https://www.furbona.org/viewlevel.html
(Mine is easier to install – it’s just a plugin – but it looks like his is a better implementation overall, less of a hack…)
-
Anonymous
Icyshard,
Sorry, I’m quite tired tonight — I’m not sure what’s going on for you – it sounds like the filter on the_content isn’t being applied. I’m thinking it might be something weird with another plugin that’s also modifying that same bit of text.
If you change the line near the bottom
add_filter('the_content', 'hide_text');
to one of the three following lines, do any of them work for you?
add_filter('the_content', 'error_text);
(this will print the error message instead of hiding the text… just curious if that will work instead)
or try changing it to
add_action('the_content', 'hide_text', 1);
or
add_action('the_content', 'hide_text', 10);
These last two change whether the plugin is applied before or after the other two.
Hope that was at least mildly coherent. ?? Let me know if any of these work – then maybe I can track down what’s going wrong for you…Hi, thanks for your help. Don’t worry, your instructions were perfectly coherent, although unfortunately they didn’t work. The first line you mentioned, add_filter(‘the_content’, ‘error_text); gave me a parse error that not only killed the admin functions, but also extended to the blog. The only way I was able to fix it was to delete the plugin and then reupload it. The other options you listed had the same effect as before–showing the “Sorry you need to be logged on” but also the text. I am using a TON of plugins –probably most notable are the show/hide comments and extended entry plugins from Scriptygoddess. I know that these plugins modify the_content, so maybe that is why I’m having problems?
Hey, while waiting for some more imput as to the possible cause of my problem with displaying the “error” message for hidding posts, I thought I’d share something I discovered.
After you do vl=X for the first time, you don’t technically ever have to write it in the body again. On the Write page, if you scroll down to the Add a New Custom Field to this Post, you can select the key “viewlevel” from the drop down menu and enter the desired level number in the Value field. From there you can either click Add Custom Field, or continue composing your entry and then click Save or Publish like normal. The Custom Field will be added automatically, just as if you had typed the code into the body.
This way could be good if you can’t remember the syntax of creating the field in the body of your post and just gives you one more alternative.Ooops – the line that crashed your blog was missing an apostrophe. Should have been
add_filter('the_content', 'error_text');
I knew there was some downside to writing while tired!
I’m going to check out those plugins you mentioned – I think I saw somewhere else on these forums today that one of them gets the post content directly from the database, bypassing any modifications previous filters (like mine) could have made. Then I’ll let you know. ??Aha! Icyshard, are you using a version of show/hide that is… ummm… older than two days old? If I understand correctly from scriptygoddess’s site, the installation instructions for the previous version included changing the line the_content(); in the index.php file to the_contentshowhide(); . Then my filter, which acts on the_content(); , never gets called! (see comment 18 here: )
https://www.scriptygoddess.com/archives/2004/05/20/show-hide-more-with-wordpress/
Two solutions: Change the line
add_filter('the_content', 'hide_text');
to
add_filter('the_contentshowhide', 'hide_text');
Or, download the most recent of showhide plugin, (posted on the 7th), which allows you to change your index.php file back to just calling the_content(); Once you make that change, my plugin should work again.wyzewoman–you are right, I was using the script that was older than 2 days ago. I uploaded the new one and adjusted my index.php file back to using the_content….unfortunately I still have the same problem as before, although pasting that one option in there with the correct syntax just prints out your “error” message right after showing the post, so that still isn’t quite working properly with any of those options you gave me, including the original code.
Hmm what else could it be?? Sorry this is such a problem, although maybe this will be able to benefit some other people if we figure it out?
As for other plugins, i’m using get comments count, comment count, kitten’s spam words, MW next/previous, post count, recent comments, recent posts, Sanitize Titles MT Style, Smart Comment Link, and WP Style switcher.
The show/hide was the one i knew for sure modified the_content, so i’m not sure that these other ones would make a difference….is there anything else you could think of??Icyshard,
Are you sure you don’t still have a call to the_contentshowhide() somewhere in your index.php file? If you turn off my plugin entirely, do you perchance see the content of the posts twice?Hmm, nope I did a search for it in my template and only saw it appear once. I turned off your plugin and the content only appeared once. Would you like to see my index file?
OK Icyshard,
I’ve figured your problem out. The showhide plugin is doing something weird – it’s directly printing out the contents of the post instead of passing them along for other plugins to modify, as it should. Here are two changes, then, to -that- plugin, that should make mine work correctly:
Change the line
add_action('the_content', 'the_contentshowhide');
to
add_action('the_content', 'the_contentshowhide',1);
This will make that filter run first.
Then, remove the line from the function the_contentshowhide()
echo $content;
and replace it with
return $content;
I’m 90% sure that will solve your problem (finally!) ??OMG IT WORKED!! Your choice of screennames is very appropriate. ??
I figured it had to be something with that plugin, due to its messing with the_content, but I probably never would’ve figured out the fix to it.
An interesting thing to note is that when you have the show/hide comments from Scriptygoddess in use, when you set show_private_posts to 1, it still displays the link to “show comments here” but it then strips out the text of the comment leaving it blank, and changes the author to “anonymous”, only leaving the date and time.
Anyway, all around it means that it has successfully blocked all of the text to the entry and its comments, so you can now be 100% sure it worked!! I’m sure this find will benefit many other people because the show/hide plugin is pretty popular, and yours works in a manner similar to Scripty’s Restricted Entries plugin for Movable Type (with its display of an error message when you don’t have permission to view a post) so I expect there will be many who will want to use it. You may want to add a note on your plugin instructions and/or leave a note at Scriptygoddess to perhaps update her plugin so that others don’t run into this problem.
I just want to thank you again for all your help and patience in getting this worked out. You’re awesome, as is your plugin! ??AnonymousThis is
Oh. My. Gosh. This is EXACTLY what I have been looking for. I have debated switching over from (another blogging program) but I wasn’t sure that WP would offer me what I wanted. This sealed the deal for me.
Thank you SO much for this. I now can have multiple “protected” categories at different levels so that different level users will be able to access different things. This is absolutely perfect.
Thanks again for this outstanding contribution to WordPress!Here’s some little things I’ve noticed with the current version of it:
This is pretty much all dealing the padlock image. First, the$site_root
wasn’t defined. Like someone else said, had to go towp-admin/options-permalink.php
and grab the code from there.
The image url still isn’t correct. If you had your site atwww.myblog.com/here/
the image url would be/here//wp-images/padlock.gif
It still displays it, just not standard, although removing the starting/
in/wp-images
would fix it, plus fix even the need for$site_root
unless you do some major changes to the layout
And finally, the “tooltip” (forget what it’s actually called, the title I think?) shows the image url markup after setting a default permalink structure. So that tooltip thing would showPermanent Link: <img src='/here//wp-images/padlock.gif' border='0'/> test
instead of justPermanent Link: test
not quite sure how to fix that one
Aside from those display issues, it’s working great.AnonymousCan anyone else access the furbona site?
Nope.
I posted the exact same question earlier this week and that message is gone, too. Mysterious, isn’t it?
Anybody got a mirror? The source I got out of Google cache is not any good. Don’t try it.
- The topic ‘ViewLevel plugin’ is closed to new replies.