Allow other role to access multiple package


// remove old action
remove_action( 'after_wpcfe_shipment_form_fields', 'wpcfe_shipment_multipackage_template', 10, 1 );

// add new action
add_action( 'after_wpcfe_shipment_form_fields', 'custom_shipment_multipackage_template', 10, 1 );

function custom_shipment_multipackage_template( $shipment_id ){

    $wpcargo_settings = !empty( get_option('wpc_mp_settings') ) ? get_option('wpc_mp_settings') : array();
    if( !array_key_exists( 'wpc_mp_enable_admin', $wpcargo_settings ) ){
        return false;
    }
	$user_roles = wpcfe_current_user_role();
        // add restriction based on current user role
	if( !( in_array( 'wpcargo_driver', (array)$user_roles ) ) ){
		$shipment       = new stdClass();
		$shipment->ID   = $shipment_id;
		$template = wpcfe_include_template( 'multiple-package.tpl' );
		require_once( $template );
	}
}
0
    0
    Your Cart
    Your cart is emptyReturn to Shop