WordPress.org

Ready to get started?Download WordPress

Forums

Show only author's posts in admin panel instead of all posts (32 posts)

  1. Nikolas
    Member
    Posted 5 years ago #

    Hello there.
    I would like to know if it is possible to find a solution to the following problem.
    Because I have several authors into my blog, I would like to know if there is any possibility of showing only the posts of the specific logged in author, instead of everyone posts. (From the wp-admin/edit.php )

    Thank you all

  2. Driftless
    Member
    Posted 5 years ago #

    Does the role-manager plugin do it for you?

    http://www.im-web-gefunden.de/wordpress-plugins/role-manager/

    It can at least prevent other from editing those posts... Maybe even prevent them from seeing them.

  3. Nikolas
    Member
    Posted 5 years ago #

    Hey, thank you for your answer.
    But it does not prevent them from seeing them. I used role manager and made a mess into my database..

  4. henkholland
    Member
    Posted 5 years ago #

    To my knowledge an author sees all posts but can only edit/change his/her own posts. Furthermore there is a filter at the top of the page, but that does not do author name filtering. But, if in that screen you click your authorname (blue in the second column) then a list with only your posts is displayed (did not know that before myself).

  5. Nikolas
    Member
    Posted 5 years ago #

    Yes, this is correct, but i am trying to find if there is a possibility of showing only his posts by default..

  6. Nikolas
    Member
    Posted 5 years ago #

    As i see the url if you clock an author is /wp-admin/edit.php?author=1

    So if there is a variable that shows the number of the author, i will put it as a link into the administrator menu.

  7. Nikolas
    Member
    Posted 4 years ago #

    so anyone?

  8. Nikolas
    Member
    Posted 4 years ago #

    hello ?

  9. Mark / t31os
    Moderator
    Posted 4 years ago #

    Sure i'll give it a go...

    What about this..

    function posts_for_current_author($query) {
    
    	if($query->is_admin) {
    
    		global $user_ID;
    		$query->set('author',  $user_ID);
    	}
    	return $query;
    }
    add_filter('pre_get_posts', 'posts_for_current_author');

    Of course that will apply to all users.. if you want to exclude say admins let me know and i'll make a change to the above..

  10. copemanm
    Member
    Posted 4 years ago #

    Hi @t310s (Telos!) - this looks great. Because I'm not a coding expert - could you tell where abouts this code needs to be inserted.

    Many thanks.
    Mark

  11. Mark / t31os
    Moderator
    Posted 4 years ago #

    functions.php of your theme will be fine..

    Like i said, it will apply to "All" users, so if you want to target users in particular then you'll need something additional to the above..

  12. copemanm
    Member
    Posted 4 years ago #

    Telos - you're a star. Thank you.

    Where would the world be without opensource and forums like this?

    Having read closely what you've written - (and I'm going to be trying it this morning) does this apply to all users within a role or all users across the system including admin?

    the former would be perfect if you are able to comment on that - apply to all users in the 'subscriber' role say... (that role has been modified to allow page writing'). I'd still like a 'supervisor' role to be able to see everything - whether it be editor or admin etc.

  13. Mark / t31os
    Moderator
    Posted 4 years ago #

    Yes, as i said before, it will apply to ALL users..

    If you want to only work for particular roles i'll need a clear defintion of what roles can see all and what can't, then i'll test some changes to the above...

    Remember this only changes the posts viewable, so it won't have any effect on whether they can actually view or edit them (if they could before, they will still be able to).. they just won't see anything other then their own..

  14. copemanm
    Member
    Posted 4 years ago #

    Hi Telos,

    I'm using the Capability manager plugin and have defined a 'Subscriber' as someone I'd like to login and view (and therefore edit) only their pages. (and I mean pages).

    You code above works perfectly for achieving that.

    If you are able to tweak the code (as you indicated above) so that that situation doesn't change... however IN ADDITION, an editor role can see all subscriber pages - or any pages on the system by default - that would be amazing.

    Thank you in advance.

    Mark

  15. Mark / t31os
    Moderator
    Posted 4 years ago #

    That's outside the scope of what the above can do..

    The above code simply sets the author parameter in query_posts to that of the current user... (pre query)..

    I can make the code apply to only a select level, but it's not going to be possible (not easily at least) to have a select level user see X levels worth of posts..

    I believe this is something you'd need to handle with plugins and modifications to said plugins. I wouldn't know where to start because i don't personally use any of the role management plugins.

    The issue i see is that in order to know which posts fit the criteria you'd need to do an additional lookup query to find which posts full under said criteria then move along that information to the pre query posts function above, which could be quite a large query if you have alot of users or posts...

    It's not to say i'm totally correct, i'm sure with a little imagination and patience such a task could be handled efficiently, right now i'm not sure i can give you a clear direction being that it's not something i've had to tackle before...

    What i tend to do when i'm looking to do X in WP (x being anything), is look for a plugin that gets as close as possible, then take out or strip what i need/don't need, from it..

  16. copemanm
    Member
    Posted 4 years ago #

    Oh OK - I misunderstood...

    if you want to exclude say admins let me know and i'll make a change to the above..

    What were you suggesting above? When you say exclude admins - I thought you meant exclude admins from the 'seeing only the user's posts' rule.

    By the way - really appreciate your input here.

  17. Mark / t31os
    Moderator
    Posted 4 years ago #

    Yes we could leave admins out of the equation or editors, i think i misinterpreted your post last time i read it, makes more sense now i've read again...

    It's just a matter of determining level first, then applying a filter if it's not a particular role..

    Gimme 5 mins, i'll go test... :)

    EDIT:

    function posts_for_current_author($query) {
    	global $user_level;
    
    	if($query->is_admin && $user_level < 5) {
    		global $user_ID;
    		$query->set('author',  $user_ID);
    		unset($user_ID);
    	}
    	unset($user_level);
    
    	return $query;
    }
    add_filter('pre_get_posts', 'posts_for_current_author');

    Editor roles equates to levels 5 through 7, so anything lower then 5 is lower then an editor role...

    http://codex.wordpress.org/Roles_and_Capabilities#User_Level_to_Role_Conversion

  18. copemanm
    Member
    Posted 4 years ago #

    Telos,

    You are nothing short of a genius, plus a very kind man... thank you so much for your generosity.

    I can see we actually live round the corner too - I'm in Berkshire.

    Be worth staying in touch - I'm always needing paid for WP programming help.

    Feel free to contact me - search for mark copeman - you'll soon find me...

    All the best, and thanks again.
    Mark.

    PS I should add your code is tested and works a treat....!

  19. Mark / t31os
    Moderator
    Posted 4 years ago #

    Glad i could help.. :)

  20. islandsofla
    Member
    Posted 4 years ago #

    This is great!! Is there any way to also hide the following on the authors admin panel:

    - Right Now/At A Glance window that lists # of posts/comments, etc

    - Comments link on the left side (or just deactivate the link)

    - Blog stats link on the left, just below the Dashboard link

    Basically, this means an author can only see their work and not the various other components/stats for the blog.

  21. justbishop
    Member
    Posted 4 years ago #

    I need this too! I tried the second code example posted by t31os_, and it DID work to only show the user posts that they had submitted in the admin area listing, but threw up all sorts of errors when I tried to log out.

    I just updated to 2.8.5 yesterday, so maybe that is causing it?

  22. Mark / t31os
    Moderator
    Posted 4 years ago #

    I'll need to see the errors to have any idea what the problem is..

    Post the error message and i'll have a look.

  23. justbishop
    Member
    Posted 4 years ago #

    Thanks, but nvm. I found a plugin called "Manage Your Posts Only" that worked w/o a hitch :)

    code.mincus.com/41/manage-your-posts-only-in-wordpress/

  24. artsy.ca
    Member
    Posted 4 years ago #

    code.mincus.com/41/manage-your-posts-only-in-wordpress/

    Too bad you can't do the same with comments on posts!

  25. pampfelimetten
    Member
    Posted 4 years ago #

    works great - and yes, I'd need the same thing for comments too.
    I looked at the code, but it seems, you have to replace the _wp_get_comment_list function in wp-admin\includes\template.php

    Somebody here with good enough knowledge of SQL Joins?

  26. pampfelimetten
    Member
    Posted 4 years ago #

  27. pampfelimetten
    Member
    Posted 4 years ago #

    see the trac ticket, theres an patch online which needs testing!

  28. nims
    Member
    Posted 4 years ago #

    I am also looking for a solution where contributors can only see and moderate comments on their posts.

  29. Firkraag85
    Member
    Posted 4 years ago #

    Hi, it is possible something like this but for comments?

  30. yakogg
    Member
    Posted 4 years ago #

    thanks for informations..

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags