WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote -1 down vote accepted

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.

share|improve this answer
    
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
1  
ok thanks again for you reply. – user3187719 Jan 28 '14 at 5:07
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

protected by Community Sep 8 '14 at 2:55

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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