comment_from in functions.php
-
Hi,
I currently developing a theme for WP and trying to figure out why comment_form doesn’t work as should when hook is stored in functions.php
Here is the code
add_filter('comment_form_defaults', 'rapid_comment_form'); function rapid_comment_form($form_options) { // Fields Array $fields = array( 'author' => '<p>' . ( $req ? '<span class="required">*</span>' : '' ) . '<input class="block_field_input content_field_input" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' placeholder="' . __( 'Name' ) . '" />' . '</p>', 'email' => '<p>' . ( $req ? '<span class="required">*</span>' : '' ) . '<input class="block_field_input content_field_input" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' placeholder="' . __( 'Email' ) . '" />' . '</p>', 'url' => '<p>' . '<input class="block_field_input content_field_input" name="url" size="30" id="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" type="text" placeholder="' . __( 'Website' ) . '" />' . '</p>', ); // Form Options Array $form_options = array( // Include Fields Array 'fields' => apply_filters( 'comment_form_default_fields', $fields ), // Template Options 'comment_field' => '<textarea id="comment" name="comment" class="block_field_input content_field_input_reply" placeholder="' . _x( '', 'noun' ) . '"></textarea>' , 'must_log_in' => '<p class="font_2">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink($post_id) ) ) ) . '</p>', 'logged_in_as' => '<div class="font_2">' . sprintf( __( 'You logged as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account"></a>' ), admin_url('profile.php'), $user_identity, wp_logout_url( apply_filters('the_permalink', get_permalink($post_id)) ) ) . '</div></div></div>', 'comment_notes_before' => '<div class="font_2">' . __( '' ) . ( $req ? $required_text : '' ) . '</div></div></div>', 'comment_notes_after' => '', // Rest of Options 'id_form' => 'form-comment', 'id_submit' => 'submit', 'title_reply' => __( '<div class="font_1"></div>' ), 'title_reply_to' => __( '<div class="font_1"> %s</div>' ), 'cancel_reply_link' => __( '<div class="font_2"></div>' ), 'label_submit' => __( 'Post Comment' ), 'title_reply_before' => __( '<div class="block_line"><div class="content_header_align">' ), 'title_reply_after' => __( '' ), ); return $form_options; }
So problem with this line
'logged_in_as' => '<div class="font_2">' . sprintf( __( 'You logged as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account"></a>' ), admin_url('profile.php'), $user_identity, wp_logout_url( apply_filters('the_permalink', get_permalink($post_id)) ) ) . '</div></div></div>',
It cannot display a username and as result shows “You logged as “. When I apply this code in comments.php everything works as should and displays username. Why?
- The topic ‘comment_from in functions.php’ is closed to new replies.