Remove view shipment column in shipment table by roles

Note: Please copy and paste this code in functions.php of your current theme.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function remove_view_shipment_callback(){
  $current_user = wp_get_current_user();
  /*
  * WPCargo Roles
  */
 
  /*
  * wpcargo_client
  * wpcargo_pending_client
  * wpcargo_employee
  * cargo_agent
  */
 
  // Remove View Shipment Column from the shipment table
  if( in_array( "wpcargo_client", $current_user->roles ) ){
    remove_action( 'wpcfe_shipment_table_header', 'wpcfe_shipment_table_header_view', 25 );
    remove_action( 'wpcfe_shipment_table_data','wpcfe_shipment_table_data_view', 25 );
  }
     
}
add_action( 'init', 'remove_view_shipment_callback' );