• I am new to WordPress and am VERY impressed so far.
    I am almost done with my BLOG.
    I have enabled a hack so that the user MUST be logged in in order to post comments. This was to rpevent/eliminate SPAM.
    But when a user tries to post a comment, my BLOG still asks for their name and email. Why can’t my blog get that info from the login just like this WordPress help BLOG does?
    Just wondering what I’m missing. THANKS!!! ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • This is a modified version of forum software and not a blog persay. That’s why it remembers.
    You can modify the wp-comments.php file to ensure that a user is logged in and then only present the necessary comment box, but leave out out the name/email boxes.
    Regards

    Thread Starter friend_of_grommit

    (@friend_of_grommit)

    Any suggestion to where in the wp-comments.php that would be? I’ve already done quite a bit of tweaking there. For instance, I made it so that comments are automatically put on the front page, but the comment box is not.
    I appreciate all your help. You’re obviously very knowledgeable! ??

    You can use the following code to get the current user info. If $user_nickname and $user_email is empty, then they are not logged in. If not, they are logged in.

    get_currentuserinfo();
    $comment_author = $user_nickname;
    $comment_author_email = $user_email;
    $comment_author_url = $user_url;

    At the bottom of wp-comments.php is the form that gets shown for comment entry. There instead of printing out the INPUTs, you can just print out these variables containing relevant user info.
    Regards

    Thread Starter friend_of_grommit

    (@friend_of_grommit)

    This worked! ??
    Now the BLOG “knows” who you are and your email based on your login. ??
    I added:
    <?php
    get_currentuserinfo();
    $comment_author = $user_nickname;
    $comment_author_email = $user_email;
    $comment_author_url = $user_url;
    ?>
    and then replaced:
    <form action="<?php echo get_settings('siteurl'); ?>/postthis.php" method="post" id="commentform">

    <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" <?=$post_disabled?> />
    <label for="author"><?php _e("Name"); ?></label> <?php if ($req) _e('(required)'); ?>
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($_SERVER["REQUEST_URI"]); ?>" />

    <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" <?=$post_disabled?>/>
    <label for="email"><?php _e("E-mail"); ?></label> <?php if ($req) _e('(required)'); ?>

    with this:
    <form action="<?php echo get_settings('siteurl'); ?>/postthis.php" method="post" id="commentform">

    <input type="hidden" name="author" id="author" value="<?php echo $comment_author; ?>" />
    <input type="hidden" name="email" id="email" value="<?php echo $comment_author_email; ?>" />
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    <input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars($_SERVER["REQUEST_URI"]); ?>" />

    <label for="comment"><?php _e("$user_nickname's Comment"); ?></label>

    <textarea name="comment" id="comment" cols="40" rows="4" tabindex="4"></textarea>
    </font>
    WORKS GREAT!!! ??
    My BLOG is <i>almost</> ready for prime time! ??

    I am interested in this as well – I have installed the hack to only allow registered users to post, and wish for it to automatically transfer the information from get_currentuserinfo() to the posted comment. I tried using the above code posted by friend_of_grommet, but it still posts the comment from Anonymous. Any further advice on this subject?

    Nevermind, I just figured it out!
    In the “hidden” input types, I just replaced $comment_author with $user_nickname and it works fine.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘This BLOG knows my name… why not my BLOG?’ is closed to new replies.