Use custom capability to manage access to order delivery process
This commit is contained in:
@@ -42,7 +42,7 @@ class Wiaas_Admin_Order_Process_Flow {
|
||||
|
||||
if ($delivery_process &&
|
||||
wp_verify_nonce($_POST['wiaas_delivery_process_navigation_nonce'], 'wiaas_delivery_process_navigation') &&
|
||||
GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' )) {
|
||||
GFAPI::current_user_can_any( 'manage_wiaas_order_delivery_process' )) {
|
||||
|
||||
self::_maybe_process_admin_step_change_action($delivery_process);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ if ( ! empty($delivery_process)) {
|
||||
</h1>
|
||||
|
||||
<?php
|
||||
if (GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' )) {
|
||||
if (GFAPI::current_user_can_any( 'manage_wiaas_order_delivery_process' )) {
|
||||
|
||||
?>
|
||||
<p>
|
||||
@@ -106,7 +106,7 @@ if ( ! empty($delivery_process)) {
|
||||
|
||||
if (! empty($delivery_process)) {
|
||||
|
||||
if ($current_step && GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' )) {
|
||||
if ($current_step && GFAPI::current_user_can_any( 'manage_wiaas_order_delivery_process' )) {
|
||||
|
||||
require 'html-delivery-process-navigation.php';
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ if ($is_current_step) {
|
||||
|
||||
$action_entry_step = $action_workflow->get_current_step($action_entry);
|
||||
|
||||
$show_entry = GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' ) ||
|
||||
$show_entry = GFAPI::current_user_can_any( 'manage_wiaas_order_delivery_process' ) ||
|
||||
($action_entry_step &&
|
||||
$action_entry_step->is_assignee($current_assignee_key));
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ class Wiaas_DB_Update {
|
||||
'20181106133553' => 'wiaas_db_update_add_installation_date_delivery_action_form',
|
||||
'20181125133553' => 'wiaas_db_update_add_country_settings_ui_fields',
|
||||
'20181125143553' => 'wiaas_db_migration_fix_user_profile_addresses', // remove after migration
|
||||
'20181125153553' => 'wiaas_db_migration_fix_countries' // remove after migration
|
||||
'20181125153553' => 'wiaas_db_migration_fix_countries', // remove after migration,
|
||||
'20181203115826' => 'wiaas_db_update_add_administrator_delivery_process_capabilities'
|
||||
);
|
||||
|
||||
public static function execute() {
|
||||
|
||||
@@ -107,7 +107,7 @@ class Wiaas_Delivery_Process {
|
||||
$delivery_process_entry = self::get_order_delivery_process_entry($order_id);
|
||||
}
|
||||
|
||||
if (empty($delivery_process_entry) || ! GFAPI::current_user_can_any( 'gravityflow_workflow_detail_admin_actions' )) {
|
||||
if (empty($delivery_process_entry) || ! GFAPI::current_user_can_any( 'manage_wiaas_order_delivery_process' )) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -323,4 +323,9 @@ function wiaas_db_update_enable_workflow_inbox_for_roles() {
|
||||
// add workflow inbox for commercial lead
|
||||
wp_roles()->add_cap( 'commercial_lead', 'gravityflow_inbox' );
|
||||
|
||||
}
|
||||
|
||||
function wiaas_db_update_add_administrator_delivery_process_capabilities() {
|
||||
|
||||
wp_roles()->add_cap('administrator', 'manage_wiaas_order_delivery_process');
|
||||
}
|
||||
Reference in New Issue
Block a user