Viewing 1 replies (of 1 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hello there,

    I hope you are doing well ??

    To delete the name and email fields you have to copy the template file ywar-product-reviews.php (wp-content/plugins/yith-woocommerce-advanced-reviews/templates/) and paste it in the following path:

    – wp-content/themes/your_active_theme/woocommerce

    If you don’t have already ‘woocommerce’ folder, create it.

    Once this is done, in the pasted file you have to change the $comment_form variable (line 54) that is actually this:

    $comment_form = array(
    					'title_reply'          => $reviews_count ? __( 'Add a review', 'yith-woocommerce-advanced-reviews' ) : __( 'Be the first to review', 'yith-woocommerce-advanced-reviews' ) . ' “' . get_the_title() . '”',
    					'title_reply_to'       => __( 'Write a reply to %s', 'yith-woocommerce-advanced-reviews' ),
    					'comment_notes_before' => '',
    					'comment_notes_after'  => '',
    					'fields'               => array(
    						'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'yith-woocommerce-advanced-reviews' ) . ' <span class="required">*</span></label> ' .
    						            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" /></p>',
    						'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'yith-woocommerce-advanced-reviews' ) . ' <span class="required">*</span></label> ' .
    						            '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-required="true" /></p>',
    					),
    					'label_submit'         => __( 'Submit', 'yith-woocommerce-advanced-reviews' ),
    					'logged_in_as'         => '',
    					'comment_field'        => ''
    				);

    by this new one:

    $comment_form = array(
    					'title_reply'          => $reviews_count ? __( 'Add a review', 'yith-woocommerce-advanced-reviews' ) : __( 'Be the first to review', 'yith-woocommerce-advanced-reviews' ) . ' &ldquo;' . get_the_title() . '&rdquo;',
    					'title_reply_to'       => __( 'Write a reply to %s', 'yith-woocommerce-advanced-reviews' ),
    					'comment_notes_before' => '',
    					'comment_notes_after'  => '',
    					'label_submit'         => __( 'Submit', 'yith-woocommerce-advanced-reviews' ),
    					'logged_in_as'         => '',
    					'comment_field'        => ''
    				);

    And finally, you have to add this code in the functions.php of your active theme:

    if (! function_exists('yith_remove_email_author_field_from_comment_form')){
        function yith_remove_email_author_field_from_comment_form($fields) {
            if(isset($fields['email'])) unset($fields['email']);
            if(isset($fields['author'])) unset($fields['author']);
    
            return $fields;
        }
        add_filter('comment_form_default_fields', 'yith_remove_email_author_field_from_comment_form');
    }

    Let us know any news, please.

    Have a nice day!

    • This reply was modified 5 years, 11 months ago by YITHEMES.
    • This reply was modified 5 years, 11 months ago by YITHEMES.
Viewing 1 replies (of 1 total)
  • The topic ‘How to remove filed name and email?’ is closed to new replies.