• Resolved Mark

    (@markjcasey)


    Hi guys

    I’m not sure if what I’m trying to do is possible. I’d like the option for registered users to reply to their own comments – no one else, just users own their own comments.

    So I’m using this bit of code…

    <?php if ($comment->comment_author_email == “[email protected]”) echo comment_reply_link(array (‘reply_text’ => ‘Respond’, ‘depth’ => $depth, ‘max_depth’ => $args[‘max_depth’])) ?>

    It works, if the comment author email matches the hard-coded email address then the respond link shows.

    Obviously I don’t want the email hard-coded in though. How do I replace “[email protected]” with the current user email?

    Thanks! : )

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Mark

    (@markjcasey)

    Yea, I’m just not sure how to slot it into my current code.

    I’ve tried…

    <?php if ($comment->comment_author_email == $current_user->user_email) echo comment_reply_link(array (‘reply_text’ => ‘Respond’, ‘depth’ => $depth, ‘max_depth’ => $args[‘max_depth’])) ?>

    …but that didn’t work.

    Did you declare global $current_user; before calling the function?

    global $current_user;
    get_currentuserinfo();
    echo $current_user->user_email;

    Tried it on my test blog and it works.

    Thread Starter Mark

    (@markjcasey)

    Ah! I have to declare that before? I’ve been declaring it all over the place haha

    <?php global $current_user;get_currentuserinfo(); $current_user->user_email; ?>
    
    <?php if ($comment->comment_author_email == $current_user->user_email) echo comment_reply_link(array ('reply_text' => 'Respond', 'depth' => $depth, 'max_depth' => $args['max_depth'])) ?>

    That seems to have done the trick.

    Thanks Joseph, appreciate the help buddy. : )

    You’re welcome.

    BTW, you don’t need $current_user->user_email; in the first line.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP help – exclusively allow users to respond to their own comments’ is closed to new replies.