First step to a workaround?
http://ww.wp.xz.cn/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.
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’ <http://wiki.ww.wp.xz.cn/?pagename=Plugin%2FRegisteredOnly> 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.
😀
Awesome!
Thank you for your help!!
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 = "";
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.
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?
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. :)