0

How to link that "logged in" in "you must be logged in to post a comment" for a post on WordPress to custom login page. So that when the user clicks on that "logged in" gets redirected to the custom login page not to the wp-login.php. Please help.

-1

You could change the whole text by adding first parameter to your comment_form function. According to the Codex, the code below might help:

$comments_args = array(
        // change the must log in text and link url
        'must_log_in'=> '<p class="must-log-in">' .  sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), YOUR_CUSTOM_LOGIN_PAGE_URL ) . '</p>'
);

comment_form($comments_args);

Please change the 'YOUR_CUSTOM_LOGIN_PAGE_URL' accordingly.

  • thanks for your help. I am quit a newbie to wordpress. can you please tell me where shall i put that code. I mean in which file. – user3187719 Jan 28 '14 at 4:57
  • You could check out the comments.php in your theme first. You could replace the comment_form(); with my code. – 1fixdotio Jan 28 '14 at 5:01
  • shall I change in comment-templte.php? – user3187719 Jan 28 '14 at 5:06
  • In my themes comment.php, there is only call for comment_form(); so i did like this <?php comment_form($comments_args); $comments_args = array( // change the must log in text and link url 'must_log_in'=> '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), 'http://mydomain.com/login' ) . '</p>' ); ?> but its not working still redirecting to same page. Please help. – user3187719 Jan 28 '14 at 7:26
  • 1
    $comments_args = array( // change the must log in text and link url 'must_log_in'=> '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), 'http://mydomain.com/login' ) . '</p>' ); comment_form($comments_args);?> I have done like this and now its working. Thanks a lot for your help. – user3187719 Jan 28 '14 at 12:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.