The comment_form_must_log_in_after WordPress action fires after the HTML-formatted ‘must log in after’ message in the comment form.
Usage
add_action('comment_form_must_log_in_after', 'your_custom_function');
function your_custom_function() {
// your custom code here
}
Parameters
- None
More information
See WordPress Developer Resources: comment_form_must_log_in_after
Examples
Add a message after ‘must log in’ message
Add a custom message after the ‘must log in’ message in the comment form.
add_action('comment_form_must_log_in_after', 'add_custom_message');
function add_custom_message() {
echo '<p><strong>Note:</strong> You can register for an account to leave comments.</p>';
}
Display a login form after the ‘must log in’ message
Show a login form right after the ‘must log in’ message in the comment form.
add_action('comment_form_must_log_in_after', 'display_login_form');
function display_login_form() {
wp_login_form();
}
Add social media login buttons
Add social media login buttons after the ‘must log in’ message.
add_action('comment_form_must_log_in_after', 'add_social_login_buttons');
function add_social_login_buttons() {
echo '<p>Or log in with:</p>';
echo '<a href="/social-login/facebook">Facebook</a> | <a href="/social-login/twitter">Twitter</a>';
}
Add a custom link after ‘must log in’ message
Insert a custom link after the ‘must log in’ message in the comment form.
add_action('comment_form_must_log_in_after', 'add_custom_link');
function add_custom_link() {
echo '<p>Need an account? <a href="/register">Register here</a>.</p>';
}
Display a notice about comment moderation
Show a notice about comment moderation after the ‘must log in’ message.
add_action('comment_form_must_log_in_after', 'display_comment_moderation_notice');
function display_comment_moderation_notice() {
echo '<p>Please note that all comments are moderated before being published.</p>';
}