WordPress.org

Ready to get started?Download WordPress

Forums

ViewLevel plugin (64 posts)

  1. skippy
    Member
    Posted 10 years ago #

    Nice, wyzewoman! A variety of options can only benefit WordPress: your plugin will appeal to many people that my modification might be intimidated by. The only advantage (in my opinion) that my solution has is that it does not even pull restricted posts from the database, so server load should be a little lighter on popular blogs with (many?) hidden posts. I was always encouraged to structure operations such that the database does all the "heavy lifting", and your code pulls only the data it needs and is going to use. As such, my modification may be a better solution for people concerned about server load. Your solution looks great, though, and should work fine for most folks.
    Good work!

  2. Tek
    Member
    Posted 10 years ago #

    =(
    I am having some problem with this hack. I keep getting an error
    Warning: Cannot modify header information - headers already sent by (output started at /home/tekwh0re/public_html/wp/wp-content/plugins/viewlevel.php:62) in /home/tekwh0re/public_html/wp/wp-admin/users.php on line 132
    Help, please?

  3. Anonymous
    Unregistered
    Posted 10 years ago #

    Can either of these two solutions be used on a whole category? - i.e. I'd like to:
    * show posts from all categories except the restricted ones on the main page
    * in the category list, I'd like all cats to appear, but the restricted ones would be marked (members only) and would lead to the login page unless one was already logged in
    Thanks!

  4. skippy
    Member
    Posted 10 years ago #

    Anonymous:
    These solutions currently only deal with posts, not categories. You might be able to take either of our private post solutions and apply the method to categories, instead.

  5. Tek
    Member
    Posted 10 years ago #

    Wyzewoman, I got it to work! I think I may have had a typ0 in there.
    Thanks!
    Now if only we could make this apply to a certian category only, it would rock the bestest!
    Thanks for the plugin! =)

  6. wyzewoman
    Member
    Posted 10 years ago #

    Tek,
    I would be fairly simple to modify my code to make it work for a certain category - you'd just need to change the function filter_posts(); that function checks a post's viewlevel and compares it to the user level, and you could change it to check the post's category and, if it was in the right category, compare the user level to the set cutoff. You'd end up changing the line if ($user_level>=$vl){ to whatever your new condition is.
    Kendra

  7. tontamoo
    Member
    Posted 10 years ago #

    Ahh. I've been looking for something like this for the longest time. From the looks of it, it should be rather painless to implement. The only thing holding me back from actually using it is that the comments are still displayed in the RSS feed. I hope you're able to fix that. In the meantime, I'll take a look at Skippy's plugin (yes, I do have to admit it does look much more intimidating for a somewhat computer-illiterate person like myself).

  8. skippy
    Member
    Posted 10 years ago #

    If you consider yourself "computer-illiterate", you're likely not to be adding (m)any other modifications to the WordPress source code. As such, you could simply copy the modified versions of the core WP files I include with the download into their respective locations, then run the wp-admin/post_level_install.php script. That's arguably even easier than installing and activating wyzewoman's plugin.

  9. Tek
    Member
    Posted 10 years ago #

    =( I'll look into it but I am not a coder. I can follow instructions but I don't know how to code. (I'm a network type computer geek so the codies are gods to me.
    I'll give it a gander however.
    I am still in the process of trying to now find a 3 coloum layout I can modify. Soon, I hope I can go live with the new WP install.

  10. wyzewoman
    Member
    Posted 10 years ago #

    OK, here's a quick hack:
    Put the following paragraph into your viewlevel.php file, right before the add_filter lines:
    function filter_cats($cat,$minuserlevel){
    get_currentuserinfo();
    global $posts, $post_meta_cache,$user_level,$category_cache;
    global $post;
    if ($user_level<$minuserlevel){
    if (is_array($posts)){
    foreach ($posts as $post){
    $thecats=$category_cache[$post->ID];
    foreach($thecats as $thiscat) {
    $catnames[]=$thiscat->cat_name;
    error_log($catnames[0]);
    }
    if(!in_array($cat,$catnames)){
    $goodposts[]=$post;
    }
    unset($catnames);
    }
    $posts=$goodposts;
    }
    }
    }

    Then, at the end of your wp-blog-header.php file, right next to where you have "filter_posts()", type "filter_cats('PrivateCategoryName',UserLevel);", where PrivateCategoryName and UserLevel are the names of the category you want private and the minimum user level. This should hide the private category postings from people who shouldn't be able to see them.

  11. Tek
    Member
    Posted 10 years ago #

    Ugh... I must be doing something wrong. Now I am getting errors again.
    Though- I did notice something wierd. When I creat a post, none of the categories that I have the option to to put them in are showing up. Everything is going to general even though I have made other categories.

  12. wyzewoman
    Member
    Posted 10 years ago #

    Hmmm... I don't have any problems writing posts. What sort of errors are you getting?

  13. Tek
    Member
    Posted 10 years ago #

    I can make post just fine... but I don't get any options for what category the post should be in, even though I made a bunch of them.
    For example, I have general, hidden, politics...
    I go to make a post but I don't get the options for general, hidden, politics, everything just defaults to general.

  14. Anonymous
    Unregistered
    Posted 10 years ago #

    Great Plugin!!!! ;-) Thanks a lot

  15. Anonymous
    Unregistered
    Posted 10 years ago #

    Just one bug: the hidden posts show up in the calendar's day-hover text. Great work though!

  16. wyzewoman
    Member
    Posted 10 years ago #

    Hey, thanks! I didn't notice that because I don't have the calendar showing on my site. I'll get right on it...

  17. Tek
    Member
    Posted 10 years ago #

    My posts seem to keep getting deleted!

  18. Anonymous
    Unregistered
    Posted 10 years ago #

    GREAT plugin. I was waiting and hoping for something like this since b2 !! I guess now it's time to upgrade my private blog to 1.2 ;-)
    The first step was very painless to install.
    So I thought I'd move on to the additional code you provided. Took me a little while to figure it out (some oddities along the way), but now it works that unregistered viewers (cat=0) will only see what is posted in general and to see anthing else they have to be at least level 1. This makes a really useful too, especially in addition with having the option of userLevel requirement on a per-post basis.
    Great! Thanks a lot.

  19. Anonymous
    Unregistered
    Posted 10 years ago #

    Actually I did find a problem: if the category to hide has at the same time a category to show (e.g. category house plus category general of which house is to hide but general to show) - in such a circumstance the messages will hide and not show up in the category to show.
    For now my workaround is to ensure an 'all public' messages will not also be filed in another category.
    Is there something one could do to have 'all public' messages show no matter into which other (hidden) category there are also filed?

  20. Anonymous
    Unregistered
    Posted 10 years ago #

    How can you show the view level of a post a viewer can't read. IE if the view level is 1 and the user's level is 1 they can read the post but if the view level is 2 they can't. So how can you display the title or something to let them know they need a higher level?

  21. Anonymous
    Unregistered
    Posted 10 years ago #

    Not sure if this is in response to what I wrote? Or are you asking how you can do that? Personally I am glad that they don't see there is something for higher level (because the password protected posts do that already).
    I've noticed another problem, I also use 'narchives.php' plugin which works great and also refers to the wp-blog-header file. The filter_cat() works fine for date and title in narchives, but when the narchives sort per category, all, even the hidden ones, will show - title and date and in which category. (So basically that what Anonymous had been asking for). Clicking onto such a title though will correctly then display no info on the posting.
    Also, the amount of postings per categories will show on the index.php page (if the tag is enabled to show number of posts in the index.php file), so that would also show that there is more than a lower level can see (would that solve your question Anonymous?).
    Right now, it just nees some planning and evaluation of importancies, i.e. for me it is not important to show how many postings per category, I am even considering to take the 'display by category' part out of the narchives, just to ensure that not even titles of hidden posts can be found. If I'd know more about coding, I am sure there are simple solutions to these situations.

  22. wyzewoman
    Member
    Posted 10 years ago #

    Wow, so many comments when I go away for a day! :-)
    I'm going to see what I can do this evening about fixing some of the issues noted above. The real difficulty here is with the WordPress plugin architecture -it makes it easy to control things like how the title of a post looks, but not yet easy to control deeper things like which posts get shown.
    So, I'm trying to think about ways in which I can get viewlevel to work more consistently -- thanks everybody for pointing out the places where it doesn't! -- with the absolute minimum amount of changes to the WordPress code itself. That's my project for tonight. I'll let you know what I work out!

  23. Tek
    Member
    Posted 10 years ago #

    Actually, I like the fact that they can't read the post. If you wanted a post that you wanted people to KNOW they can't read, just use the default ability to password protect entries. The point IMHO is not to get harassed because people can SEE there is something they CAN'T see.

  24. Anonymous
    Unregistered
    Posted 10 years ago #

    Hiding the posts completely can be accomplished by making a post 'private'. If there isn't anything showing posts of higher levels then how will anyone ever be able to read them or know they exsists? Do you expect people to just sign up?
    I thought this plugin would be nice for making posts you want the masses to see then 'users' who sign up will get to so more personal posts but no one will even know you need a higher user level if there's nothing showing user levels at all.

  25. Anonymous
    Unregistered
    Posted 10 years ago #

    If you make the post "private" only you can see it. If you want to use this hack and let people see certain posts, then look at your userlist and give them the level that they need to view it. Once again, when people register, it is up to YOU what level you want them to have. If you want to make post that only registered users can see, then make the post say... level 5 then give all new users a defaul level of 5. If you want nothing to show up, then just make an open post that says "You must be registered to view new posts" and make that a level 0 and everother post a level 5.

  26. Anonymous
    Unregistered
    Posted 10 years ago #

    No, no, there is a BIG difference in having a post PRIVATE (which only shows in the admin - edit views) versus having something only visible to a certain level of users without disgruntling the other users who can not read it. I do not want to read my blog in the edit/admin views. I really think this ViewLevel plugin one of the best new add-ons.

  27. Anonymous
    Unregistered
    Posted 10 years ago #

    An addition: There are situations where you do not want to 'tempt' people to sign up and thos who should sign up will know so. An example is a Home Association site I am working on. These people do NOT want the general public to read their stuff but there are some general things which apply for non-members too, for example the date of the next big garage sale or some parade in that area. Some people like to know whom to contact with questions about the area. General public. In situations like this it is very convenient to have just very specific categories visible for level0 users.
    I've now incorporated 4 levels: all public (0) - general home association member (1) - board members (3) - general admin (5). For level 3 and 5 there are only singular posts set to their level, some private talk between board members or some communication between admins which are not of interest to the general community (like: 'it is time to set mrX back to level0, he has moved away 2 days ago).
    The password protected postings have always the problem of needing to tell somebody a password and then to change that password if you don't want them to see it again because you've gotten into a real bad fight with them and knocked their teeth out. Changing a user level is easy to do and will accomplish filtering posts and categories at the same time.
    Well, just my thoughts on this plugin.

  28. Anonymous
    Unregistered
    Posted 10 years ago #

    Pardon me while I ask a silly question..
    I already have like 500 posts. How could I set a default user level for all those posts? I tried looking into phpmyadmin but I couldn't find a way to add "vl=1" to the post field.

  29. Anonymous
    Unregistered
    Posted 10 years ago #

    Thank you! I was thinking gosh I got to edit all those posts and what if I don't want to use the view level in the future, I have to edit all those posts again!

  30. Icyshard
    Member
    Posted 10 years ago #

    Wyzewoman- I installed your plugin and for the most part it works correctly. However, when I set the show_private_posts to 1, while it DOES show the message "Sorry you need to be logged in to see this post", it also goes on to display the actual post contents right below it, defeating the purpose of the plugin.
    It works perfectly in hiding the post and then displaying it to appropriate levels when I have show_private_posts to 0. I made the modification to wp-blog-header as well as whatever else was suggested.
    Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.