0

I've got the following code:

function pietergoosen_persoonlike_kommentaar_velde($fields) {

    $commenter = wp_get_current_commenter();
    $req = get_option( 'require_name_email' );
    $aria_req = ( $req ? " aria-required='true'" : '' );

    $fields =  array(

  'author' =>
'<p class="comment-form-author"><label for="author">' . __( 'Naam', 'pietergoosen' ) .
( $req ? '<span class="required">*</span>' : '' ) . '</label> ' .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
'" size="30"' . $aria_req . ' /></p>',

  'email' =>
'<p class="comment-form-email"><label for="email">' . __( 'E-pos Adres', 'pietergoosen' ) .
( $req ? '<span class="required">*</span>' : '' ) . '</label> ' .
'<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) .
'" size="30"' . $aria_req . ' /></p>',

  'verwysing' =>
'<p class="comment-form-verwysing"><label for="verwysing">' . __( 'Waar het jy van die webtuiste gehoor', 'pietergoosen' ) . '</label>' .
'<input id="verwysing" name="verwysing" type="text" value="' . esc_attr( $commenter['comment_author_verwysing'] ) .
'" size="30" /></p>',
);
return $fields;
}

 add_filter('comment_form_default_fields','pietergoosen_persoonlike_kommentaar_velde');

I got this code from a tutorial. I want to edit the 'Leave a reply', 'Your email address will not be published. Required fields are marked *' and the comment box and 'post a comment' button. How do I edit this code and include the changes i want to do. I'm stuggeling to understand how to implement what is given in the codex. I'm using Twenty Twelve child theme

0

I don't think this the code/fucntion you want to change, This code/fucntion is just creating the form fields. You should look in your comments.php file for the changes that you are asking for.

0

I work a solution to my problem> for everyone that need to change the output of the comment_form, here is how i did it. Change it to any language you want, mine is in Afrikaans. Just to add a note, do not remove any $arg as this might crash any custom validation method that you have

function pietergoosen_persoonlike_kommentaar_velde($args = array(), $post_id = null ) {
if ( null === $post_id )
    $post_id = get_the_ID();
else
    $id = $post_id;

$commenter = wp_get_current_commenter();
$user = wp_get_current_user();
$user_identity = $user->exists() ? $user->display_name : '';

$req      = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html5    = isset( $args['format'] ) && 'html5' === $args['format'];
    $fields =  array(

    'author' =>
    '<p class="comment-form-author"><label for="author">' . __( 'Naam', 'pietergoosen' ) .
    ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' .
    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
    '" size="30"' . $aria_req . ' /></p>',

    'email' =>
    '<p class="comment-form-email"><label for="email">' . __( 'E-pos Adres', 'pietergoosen' ) .
    ( $req ? '<span class="required">*</span>' : '' ) . '</label> ' .
    '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) .
    '" size="30"' . $aria_req . ' /></p>',

    'verwysing' =>
    '<p class="comment-form-verwysing"><label for="verwysing">' . __( 'Waar het jy van die webtuiste gehoor', 'pietergoosen' ) . '</label>' .
    '<input id="verwysing" name="verwysing" type="text" value="' . esc_attr( $commenter['comment_author_verwysing'] ) .
    '" size="30" /></p>',
);

$required_text = sprintf( ' ' . __('Velde wat verlang word is gemerk %s'), '<span class="required">*</span>' );

$arg = array(
    'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
    'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Deel jou mening oor die artikel', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
    'must_log_in'          => '<p class="must-log-in">' . sprintf( __( 'Jy moet <a href="%s">ingeteken</a> wees om jou mening te lig.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Jy is ingeteken as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Teken uit die rekening uit">Teken uit?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
    'comment_notes_before' => '<p class="comment-notes">' . __( 'Jou e-pos adres sal onder geen omstandighede gedeel word met enige iemand nie.' ) . ( $req ? $required_text : '' ) . '</p>',
    'comment_notes_after'  => '<p class="form-allowed-tags">' . sprintf( __( 'Baie dankie indien jy besluit het om jou mening te lig oor die artikel. Neem asseblief kennis dat alle menings op alle artikels eers gemodereer word voor dit geplaas word.' )) . '</p>',
    'id_form'              => 'commentform',
    'id_submit'            => 'submit',
    'title_reply'          => __( 'Deel jou mening met ons' ),
    'title_reply_to'       => __( 'Deel jou meningmet ons in verband met %s' ),
    'cancel_reply_link'    => __( 'Verwyder mening' ),
    'label_submit'         => __( 'Stuur jou mening' ),
    );
return $arg;
}

add_filter('comment_form_defaults', 'pietergoosen_persoonlike_kommentaar_velde');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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