How to add assigned client email in notification
Here’s a sample code for getting and saving the assigned client’s email as well as adding a new email meta tag.
Paste this code on your active theme’s functions.php file.
function save_assigned_client_email_callback($shipment_id) { $assigned_client_id = get_post_meta($shipment_id, 'registered_shipper', true); $args = array( 'include' => [$assigned_client_id], 'fields' => ['user_email'], ); $email = get_users($args)[0]->user_email; update_post_meta($shipment_id, 'client_reg_email', $email); } add_action('after_wpcfe_save_shipment', 'save_assigned_client_email_callback', 10, 2); function add_assigned_client_email_metatag( $tags ){ $tags['{client_reg_email}'] = 'Client Registered Email'; return $tags; } add_filter( 'wpc_email_meta_tags', 'add_assigned_client_email_metatag' );
After pasting and saving the code, refresh your wordpress dashboard then navigate to WPCargo -> Client Email Settings and as you scroll down , you will see that a new email meta tag called “client_reg_email” will appear.
Copy the email meta tag and paste it on the “Mail To:” field and hit Save.