Support » Plugins » PHP Guru’s Help Needed.

  • Resolved trivum


    I recently made a hack into the wp-admin/edit.php file so that when users (authors/contributors/etc.) were in their backend and managing their posts, they only saw the posts they had made, not everyone esle’s.

    I found this line:


    and replaced it with the following:

    if (!current_user_can(‘edit_others_posts’))
    $thisauthor = ‘&author=’ . $user_ID;
    wp(‘what_to_show=posts&posts_per_page&=15&order=$order&orderby=$orderby’ . $thisauthor);

    That did the trick. But now when I use the filter post option (pending review, published, any), it doesn’t work.

    Any idea how I can get both functions to work?

    Thanks for any suggestions.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Anyone with ideas for this? Thanks.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Why did you remove the $post_status_q variable from the call to the wp() function?

    Try adding it back.

    Why did you remove the $post_status_q variable from the call to the wp() function?

    Try adding it back.

    I did try that before, but maybe I’m not getting the right syntax or something. I tried it in a few different spots.

    Any suggestions for how it might go?

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Exactly the same as you have it in your post above:


    The double quotes around that string are key here. You can’t use single quotes like you do in your second example. Whenever you’re using $variables inside a string, it must be double quoted.

    Thanks for the suggestion, but it still doesn’t seem to quite be working. Maybe I’m still doing something wrong. Per your suggestions, this is what I’m putting in:

    if (!current_user_can('edit_others_posts'))
    $thisauthor = '&author=' . $user_ID;
    wp("what_to_show=posts&post_status_q&posts_per_page&=15&order=$order&orderby=$orderby" . $thisauthor);

    Still not right. Compare Otto’s line to yours:




    Use the dollar sign (making it a PHP variable), not the ampersand, to prefix post_status_q.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Yep. What’s more, your code is overkill. Eliminate all that extra variable and concatenation work.

    Edit: Removed non-working code. I guess I’m confused about what you were trying to do in the first place.

    Great! Excellent! Everything seems to work – I put in the $ instead of the &. Not knowing php, I didn’t even notice at first.

    Otto – your more streamlined code didn’t seem to work for me. I wasn’t able to see any posts under Manage when I tried it, but maybe it was just how my particular system was interacting with it.

    By the way, if either of you have any say-so about the core code, I would suggest adding this. I think it would help a lot if the users that are contributing to the blog don’t have to wade through everyone else’s posts in their Manage section. It makes it much more user-friendly. I can also see situations (such as mine) where the Administrator wants the contributors to feel they have their own personal backend section.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘PHP Guru’s Help Needed.’ is closed to new replies.