-
Website
http://fortes.com/ -
Original page
http://fortes.com/2005/05/postlevels-021/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
vektormedia
1 comment · 1 points
-
ZenemiG
1 comment · 1 points
-
Charbax
1 comment · 6 points
-
subikar
1 comment · 1 points
-
x11tech
8 comments · 1 points
-
-
Popular Threads
so, it's only natural to think that empty() will work. however, in php, if $var is equal to 0 (zero), empty($var) will return true.
i propose you change
// Don't bother unless someone is logged in
if (!empty($user_level))
to
// Don't bother unless someone is logged in
if (isset($user_level))
and change is_post_level() function accordingly.
anyway, just thought i'd bring this to your attention. thanks for a quick 1.5.1 fix :)
~crash
I'll change this to an option in the next version.
Make sure you're logged out of the site before you view the RSS feed, as you'll see the private posts if you're logged in (it's all browser-cookie based)
This is my site. http://sims2.tatatee.com/main/
I can set up a test user for you if you need.
I entered post_levels in the password box and not the custom field box. My bad.
Thanks!
You will either have to downgrade to 1.5, or live without the post levels plugin until 1.5.1.1 :(
I just opened my site up today again to search engines and almost immediately msnbot has been all over it. I just took a look at my users online page and it showed msn bot at being on the page of one of my level 2 posts.
So basically, I'm thinking - how did the bot get there in the first place if the post isn't viewable to users who aren't logged in? And did it actually see/index anything?
Thanks, valerie (spoken-for.org)
I was always looking for a plugin like this. With WP 1.2 I tried out Viewlevel but wasn't very exhalted with the features it provided. This was also because of the poor WP API.
Now a new major release is out and I saw your new plugin doing much the same as the old abandoned Viewlevel. This day I installed it on my test blog and ran into the same problem as all others did with WP 1.5.1. Anyway I wanted this to work as it was supposed to and so I built a solution where it isn't necessary to touch any WP original code. The good thing to say about it: It works. The bad: I am not sure whether I used variables in this fix I shouldn't have.
So here it is. All code has to be added to your post-levels.php file.
1.) Find the line "add_filter('posts_where', 'postlevel_posts_where');". Insert a new line after it with "add_filter('the_posts', 'postlevel_posts');"
2.) Before the "?>" insert the following code:
function postlevel_posts($where)
{
if (count($where) == 0)
{
//
// this is a workaround for WP 1.5.1 until it is somehow fixed
global $wpdb, $user_ID, $postlevel_key, $user_level;
$posts = $wpdb->get_results($request);
if (count($posts) == 1) {
if ('publish' != $posts[0]->post_status) {
if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
// User must be logged in to view unpublished posts.
$posts = array();
} else {
if ('draft' == $posts[0]->post_status) {
// User must have edit permissions on the draft to preview.
if (! user_can_edit_post($user_ID, $posts[0]->ID)) {
$posts = array();
}
} elseif ('private' == $posts[0]->post_status) {
// here lies the problem in the main code, so we changed this here
if (($posts[0]->post_author != $user_ID)
&& !($postlevel_key == $posts[0]->meta_key
&& intval($user_level) >= intval($posts[0]->meta_value))) {
$posts = array();
}
}
}
}
}
//
return $posts;
}
return $where;
}
That's all. Warning: This comes with no warranty. As soon as there is an "official" API, this should be removed because of possible security holes. Anyway: Enjoy!
McShelby (normally just Shelby)
the only problem i found was if i logged-out and manually tried to access a PL-ed post, i got a dirty 404, instead of a nice WP redirect.
since it requires you make a post private wouldn't that keep it out of the viewing pages ?
when you mean a certain userlevel can see it do you mean in the admin only or in the actual blog pages
i'm using WP 1.5.1 and haven't been able to make much use of post_levels
Besides that if not flagged "private" your new "published" post wil be announced at the update service (by default http://rpc.pingomatic.com/).
Nevertheless a user can edit another post even if it's flagged private and post_levels plugin is active if his' userlevel is higher than that of the writer. Maybe you can tweak the levels of your users by providing an "edit user" with level 9 and all other user not higher than 8? Just a thought.
---------------------------
--- post-levels.php.txt 2005-05-15 00:43:41.000000000 +0300
+++ post-levels.php 2005-07-28 10:43:05.205061888 +0300
@@ -32,9 +32,8 @@
if (function_exists('add_filter'))
{
global $user_level; get_currentuserinfo();
-
// Don't bother unless someone is logged in
- if (!empty($user_level))
+ if (isset($user_level))
{
add_filter('posts_join', 'postlevel_posts_join');
add_filter('posts_where', 'postlevel_posts_where');
@@ -50,21 +49,21 @@
}
// Whether the current posts is of the given level
- function is_post_level($level = 0)
+ function is_post_level($level = -1)
{
global $postlevel_key;
$val = get_post_custom_values($postlevel_key);
if (!empty($val))
return ($val == $level);
else
- return ($level == 0);
+ return ($level == -1);
}
}
else
{
// Not logged in, use define fast functions that don't use the DB
function is_private() { return false; }
- function is_post_level($level = 0) { return ($level == 0); }
+ function is_post_level($level = -1) { return ($level == -1); }
}
}
}
I want to let folks know about a strange behavior I have encountered with Soren's (and perhaps the original) Post-Levels plugin. The plug-in works great in Internet Explorer (PC & Mac), but for me, Does not work in Firefox (PC & Mac) or Safari (Mac). Am I the only one with this problem?
Thanks again to Filipe, Soren, and any other contributors for this great plug-in.