How to configure users’ capabilities on the Frontend dashboard?
Go to Admin Dashboard > WPCargo > Frontend Dashboard for the updates.
Restrict all users to create shipment
Check the checkbox for Disable Create Order page to restrict users on creating shipments. Note: Administrators will also be restricted on creating shipment through Frontend Dashboard but is able to create through wp-admin.
Allow Employee to access all shipments
Check the box to allow employee to access all your shipments. To allow other users to access your shipments, please check here.
Allow users to access frontend dashboard when logging in
Under Access Frontend Dashboard setting, choose from the list of what user role would you like to allow to access the dashboard.
Allow users to update shipments
Under Update Shipment Roles setting, choose from the list of what user role would you like to allow to update shipments.
Allow users to delete shipments
Under Delete Shipment Roles setting, choose from the list of what user role would you like to allow to delete shipments.
Allow users to add and update shipments
By default, only administrator and employees are allowed to add shipment. To allow other users to add shipments, copy and paste below codes on your child theme’s functions.php file.
add_filter( 'wpcfe_add_shipment_role', 'custom_add_shipment_role' ); add_filter( 'wpcfe_can_edit_fields_roles', 'custom_add_shipment_role' ); function custom_add_shipment_role( $roles ){ //Allow clients to add shipments $roles[] = 'wpcargo_client'; //Allow agents to add shipments $roles[] = 'cargo_agent'; return $roles; }
For the user to be able to see the shipments he has added on his dashboard, add the code below.
add_action( 'after_wpcfe_save_shipment', 'assign_current_client_to_shipment', 10, 2 ); function assign_current_client_to_shipment( $shipment_id, $data ){ $user_id = get_current_user_id(); $user_role = wpcfe_current_user_role(); //To show shipment created by the client on client's list of shipments if( in_array( 'wpcargo_client', $user_role ) ){ update_post_meta( $shipment_id, 'registered_shipper', $user_id ); } //To show shipment created by the agent on agent's list of shipments if( in_array( 'cargo_agent', $user_role ) ){ update_post_meta( $shipment_id, 'agent_fields', $user_id ); } }
NOTE: To restrict sections that can be accessed by the users you allowed to add shipments, check on How to restrict user to access specific shipment details section? guide.