Auto Assign Shipment per User Role in Import and Add Parcel if User is an Agent
Assign Shipment during Import if User is an Employee
Available hook:
wpcie_after_save_meta_csv_import – is a hook used to add conditions or modifications when saving shipment using the import/export addon
You can enable auto assign shipment using the import/export if the logged in user is an Employee.
Copy and Paste the following code in the functions.php of your current theme.
//Shipments will appear on the dashboard of the employee who imported the shipment. function assign_shipment_to_employee_import( $shipment_id ){ if( ( can_wpcfe_add_shipment() || can_wpcfe_update_shipment() ) && in_array( 'wpcargo_employee', wpcfe_current_user_role() ) && !isset( $data['wpcargo_employee'] ) ){ // Assign Shipment to Employee when user has a role of Employee update_post_meta( $shipment_id, 'wpcargo_employee', get_current_user_id() ); } } add_action('wpcie_after_save_meta_csv_import', 'assign_shipment_to_employee_import');
Assign Shipment during Add Parcel if User is an Agent
You can enable auto assign shipment on shipment rate if the logged in user is an Agent.
Copy and Paste the following code in the functions.php of your current theme.
/***********************************/ // this will auto assign shipment to agent if he/she is logged when adding shipment through Add Parcel // to auto assign shipment to branch manager, use this user role "wpcargo_branch_manager" function auto_assign_agents( $shipment_id ){ $current_user = wp_get_current_user(); if( ( can_wpcfe_add_shipment() || can_wpcfe_update_shipment() ) && in_array('cargo_agent', $current_user->roles) && !isset( $data['agent_fields'] )){ update_post_meta( $shipment_id, 'agent_fields', $current_user->ID ); } } add_action('wpcsr_after_save_shipment', 'auto_assign_agents');