• There are already topics about this but they either have dead links or the php plugin doesn’t work, etc, etc. Also, none are in the How-To and Troubleshooting section, which I really think this belongs in.

    It seems obvious to me that if there are multiple authors, and if an author is logged in, that that author should be who shows up when posting, not “Anonymous”. There shouldn’t even be the Name/email/website form available to fill.

    This should also make it so that the author can edit his/her own comments, but that’s a feature. The having to manually type in your info even when you’re logged in is a bug.

    What I’d like (for now) is a workaround (and eventually it to be fixed).

    Many thanks, and I’m sorry if a real, working answer is already in this forum and I just didn’t find it.

Viewing 12 replies - 1 through 12 (of 12 total)
  • First step to a workaround?

    https://www.ads-software.com/support/topic.php?id=21364#post-121465

    Shouldn’t be too hard to shift the code there to work with this issue. Let me know, and I’ll mix up a brew.

    Thread Starter Zachariah

    (@zachariah)

    yeah, that’s pretty close, but it seems you still have to type in the name, but it is better that it makes sure it’s not someone else’s name

    it you would be so kind I’d love it to either pre-fill the name, or not even ask for it if an author is logged in

    also I plan to use the ‘Registered Only Plugin’ <https://wiki.www.ads-software.com/?pagename=Plugin%2FRegisteredOnly&gt; so hopefully the code wouldn’t conflict with that at all.

    ??

    Don’t use that plugin, but doubt it will conflict with this. Just stick the following into wp-comments-post.php, just after these variables are set from the comment’s content:

    get_currentuserinfo();

    if ($user_login && empty($comment_author)) {
    $comment_author = $user_nickname;
    $comment_author_email = $user_email;
    $comment_author_url = $user_url;
    }

    Remove ” && empty($comment_author)” if you need to make sure logged-in users always comment under their own author info.

    Thread Starter Zachariah

    (@zachariah)

    ??

    Awesome!

    Thank you for your help!!

    Thread Starter Zachariah

    (@zachariah)

    I’m a little nervous where to put it, do you have a line number for me?

    I haven’t altered the code yet, so it’s the exact same one out of the .zip file I downloaded.

    thanks again!!

    Unh, looks like I need to modify this a bit. I’ve been working on 1.5 today, and only just discovered 1.2.x’s wp-comments-post.php setup and variables are rather different (I love developers!).

    Anyway, for 1.2.x, around line 60 of wp-comments-post.php, you’ll find this:

    // If we"ve made it this far, let"s post.

    if(check_comment($author, $email, $url, $comment, $user_ip)) {
    $approved = 1;
    } else {
    $approved = 0;
    }

    Change it to this:

    // If we"ve made it this far, let"s post.

    get_currentuserinfo();

    if ($user_login && empty($author)) {
    $author = $user_nickname;
    $email = $user_email;
    $url = $user_url;
    }

    if(check_comment($author, $email, $url, $comment, $user_ip)) {
    $approved = 1;
    } else {
    $approved = 0;
    }

    For 1.5, just put the code I have in the previous post right after these variables (which are near the top):

    $comment_author = $_POST["author"];
    $comment_author_email = $_POST["email"];
    $comment_author_url = $_POST["url"];
    $comment_content = $_POST["comment"];

    $comment_type = "";

    Thread Starter Zachariah

    (@zachariah)

    And…. It Works!!!!

    Pretty cool!

    This is totally not working for me. The code looks like:

    // If we’ve made it this far, let’s post.

    get_currentuserinfo();

    if ($user_login && empty($author)) {
    $author = $user_nickname;
    $email = $user_email;
    $url = $user_url;
    }

    if(check_comment($author, $email, $url, $comment, $user_ip)) {
    $approved = 1;
    } else {
    $approved = 0;
    }

    I am logged in and the fields are not pre-populating. Any thoughts?

    The fields are not populated by the code, since that would have to exist (along with some modifications) in the wp-comments.php file to do it. The above simply assures that a logged-in user will have his or her comment posted under their login info.

    Thread Starter Zachariah

    (@zachariah)

    ok, so I did that hack above on 1.2 and I’d really like to upgrade to 1.5, but…

    1. (I think this is the case (it looks like this is a new feature of 1.5) and) I want to know if this hack is even needed in 1.5?

    2. If this isn’t a new feature in 1.5 (logged in users posting as themselves), then is some of the code above appropriate for 1.5 to accomplish the same thing as before.

    3. Will my upgrade have any problems due to having used this hack?

    Kafkaesqui

    (@kafkaesqui)

    1. Shouldn’t be. Something much like it was added to the core. Using the default theme in 1.5 makes this very obvious, as name/email/url fields are replaced with a little note showing your login, and a logout link.

    2. Ibid.

    3. Doubtful. I used it, and look where I am. :)

    Thread Starter Zachariah

    (@zachariah)

    Awesome!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Logged in users NOT posting as Anonymous’ is closed to new replies.