Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 0 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 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 at 5:01
    
shall I change in comment-templte.php? –  user3187719 Jan 28 at 5:06
1  
ok thanks again for you reply. –  user3187719 Jan 28 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 at 12:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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