The comment_form_logged_in_after WordPress PHP action fires after the is_user_logged_in()
check in the comment form.
Usage
add_action('comment_form_logged_in_after', 'your_custom_function', 10, 2); function your_custom_function($commenter, $user_identity) { // your custom code here }
Parameters
$commenter
(array): An array containing the comment author’s username, email, and URL.$user_identity
(string): If the commenter is a registered user, the display name; blank otherwise.
More information
See WordPress Developer Resources: comment_form_logged_in_after
Examples
Display a Welcome Message
Display a welcome message to the logged-in user above the comment form.
add_action('comment_form_logged_in_after', 'display_welcome_message', 10, 2); function display_welcome_message($commenter, $user_identity) { echo '<p>Welcome, <strong>' . $user_identity . '</strong>! Feel free to leave a comment.</p>'; }
Show Custom User Information
Display custom user information in the comment form for logged-in users.
add_action('comment_form_logged_in_after', 'display_custom_user_info', 10, 2); function display_custom_user_info($commenter, $user_identity) { // Get user object by email $user = get_user_by('email', $commenter['comment_author_email']); // Get user's custom field value $custom_field_value = get_user_meta($user->ID, 'custom_field', true); echo '<p>Your custom field value is: ' . $custom_field_value . '</p>'; }