// add phone number
// Add phone number field
function add_review_phone_field_on_comment_form() {
echo '<p class="comment-form-phone uk-margin-top"><label for="phone">' . __( 'شماره موبایل', 'text-domain' ) . '</label><span class="required">*</span><input class="uk-input uk-width-large uk-display-block" type="text" name="phone" id="phone"/></p>';
}
add_action( 'comment_form_logged_in_after', 'add_review_phone_field_on_comment_form' );
add_action( 'comment_form_after_fields', 'add_review_phone_field_on_comment_form' );
// Save phone number
add_action( 'comment_post', 'save_comment_review_phone_field' );
function save_comment_review_phone_field( $comment_id ){
if( isset( $_POST['phone'] ) )
update_comment_meta( $comment_id, 'phone', esc_attr( $_POST['phone'] ) );
}
function print_review_phone( $id ) {
$val = get_comment_meta( $id, "phone", true );
$title = $val ? '<strong class="review-phone">' . $val . '</strong>' : '';
return $title;
}
// List in admin list table
// add_filter('manage_edit-comments_columns', 'my_add_comments_columns');
// function my_add_comments_columns($my_cols) {
// $temp_columns = array(
// 'phone' => 'Phone'
// );
// $my_cols = array_slice($my_cols, 0, 3, true) + $temp_columns + array_slice($my_cols, 3, NULL, true);
// return $my_cols;
// }
// add_action('manage_comments_custom_column', 'my_add_comment_columns_content', 10, 2);
// function my_add_comment_columns_content($column, $comment_ID) {
// global $comment;
// switch ($column) :
// case 'phone' : {
// echo get_comment_meta($comment_ID, 'phone', true);
// break;
// }
// endswitch;
// }
add_filter('woocommerce_product_reviews_table_columns', 'woocommerce_product_reviews_table_columns');
function woocommerce_product_reviews_table_columns($my_cols) {
$my_cols['phone'] = __('Phone', 'woocommerce');
return $my_cols;
}
add_filter('woocommerce_product_reviews_table_column_phone_content', 'woocommerce_product_reviews_table_column_phone_content', 10, 2);
function woocommerce_product_reviews_table_column_phone_content($output, $item) {
$phone = get_comment_meta($item->comment_ID, 'phone', true);
return $phone;
}