Comments 3Hung started the conversationFebruary 12, 2025 at 6:31am function custom_b2bking_show_column_data($column, $post_id) { switch ($column) { case 'company_name': // Lấy dữ liệu từ post meta $company_name = get_post_meta($post_id, 'b2bking_custom_field_618469', true); if (empty($company_name)) { $company_name = get_post_meta($post_id, '_b2bking_custom_field_618469', true); } echo !empty($company_name) ? esc_html($company_name) : 'N/A'; break; case 'customer_email': $customer_email = get_post_meta($post_id, 'b2bking_request_custom_quote_email', true); if (empty($customer_email)) { $customer_email = get_post_meta($post_id, '_b2bking_request_custom_quote_email', true); } echo !empty($customer_email) ? esc_html($customer_email) : 'N/A'; break; case 'customer_phone': $customer_phone = get_post_meta($post_id, 'b2bking_custom_field_617057', true); if (empty($customer_phone)) { $customer_phone = get_post_meta($post_id, '_b2bking_custom_field_617057', true); } echo !empty($customer_phone) ? esc_html($customer_phone) : 'N/A'; break; } } add_action('manage_b2bking_conversation_posts_custom_column', 'custom_b2bking_show_column_data', 10, 2); // 2️⃣ Thêm các cột mới vào bảng Conversations function custom_b2bking_add_columns($columns) { $columns['company_name'] = __('Tên Công Ty', 'b2bking'); $columns['customer_email'] = __('Email', 'b2bking'); $columns['customer_phone'] = __('Số Điện Thoại', 'b2bking'); return $columns; } add_filter('manage_edit-b2bking_conversation_columns', 'custom_b2bking_add_columns'); // 3️⃣ Lưu dữ liệu khi khách hàng gửi form function save_b2bking_custom_fields($post_id) { if (get_post_type($post_id) !== 'b2bking_conversation') { return; } if (isset($_POST['b2bking_request_custom_quote_email'])) { update_post_meta($post_id, 'b2bking_request_custom_quote_email', sanitize_email($_POST['b2bking_request_custom_quote_email'])); update_post_meta($post_id, '_b2bking_request_custom_quote_email', sanitize_email($_POST['b2bking_request_custom_quote_email'])); } if (isset($_POST['b2bking_custom_field_617057'])) { update_post_meta($post_id, 'b2bking_custom_field_617057', sanitize_text_field($_POST['b2bking_custom_field_617057'])); update_post_meta($post_id, '_b2bking_custom_field_617057', sanitize_text_field($_POST['b2bking_custom_field_617057'])); } if (isset($_POST['b2bking_custom_field_618469'])) { update_post_meta($post_id, 'b2bking_custom_field_618469', sanitize_text_field($_POST['b2bking_custom_field_618469'])); update_post_meta($post_id, '_b2bking_custom_field_618469', sanitize_text_field($_POST['b2bking_custom_field_618469'])); } } add_action('save_post', 'save_b2bking_custom_fields'); Attached files: screenshot.png 2,330WebWizards replied3 weeks ago on February 13, 2025 at 2:23pmHi, Do you want to be able to manually add this info (email, phone, company name) to each conversation and save it? You can use this code: https://pastecode.io/s/1o9ot5k9 It creates 3 fields on the edit conversation page: It will show here: Sign in to reply ...
Attached files: screenshot.png
Hi,
Do you want to be able to manually add this info (email, phone, company name) to each conversation and save it?
You can use this code: https://pastecode.io/s/1o9ot5k9
It creates 3 fields on the edit conversation page:
It will show here: