• Resolved Philip

    (@artdev)


    hi to community,

    i have twirl my brain all day to find how i can show a button or something else inside a loop (single.php) if the logged in user is the author of the post.

    i have try all the conditional tags in the documentation…but with no luck…

    now i try this:

    <?php
    global $current_user;
    get_currentuserinfo();
    if (is_user_logged_in() && (current_user_can('edit_posts') || $current_user->ID == $post->post_author) ) {
    echo 'button or something';
    }
    ?>

    but with this every logged in member can see the “button or something”,

    does anyone know how i can do this?

    thanks a lot,
    Philip

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Philip

    (@artdev)

    ok, i found what i need/you need to do for this….

    first step:
    need to get the ID of the user viewing the page

    second step:
    need to check the ID against $post->post_author and echo some content

    so how to compile this:
    1. before the loop get the ID of the user viewing the page

    <?php
    global $current_user;
    get_currentuserinfo();
    ?>

    2. inside your loop check the ID against $post->post_author

    <?php
    if ($post->post_author == $current_user->ID)
    echo 'AUTHOR CONTENT HERE';
    ?>

    i know a lot of people searching a solution for this, hope you enjoy it…:)

    love you WordPress,
    all the best!!!

    Philip

    Profusion

    (@profusion)

    Great Post

    Just what I needed – thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘IF IS post author/editor show content – ELSE hide’ is closed to new replies.