GravityFlow Filter Inbox for a user by specific workflow steps

Requirement

  • User has multiple roles
  • Multiple roles are assignees in form workflows
  • For specific user, even though user has multiple roles, limit entries shown in the inbox to specific steps only
<?php
/*
 * Limit GravityFlow Pages to only show entries at a specific step
 * */


add_action('gravityflow_inbox_search_criteria', 'sb_gravityflow_inbox_search_criteria_inbox', 10, 1);
function sb_gravityflow_inbox_search_criteria_inbox($search_criteria)
{
    // Limit filter to a specific page. This is the page the inbox is displayed on
    if (is_page(7428)) { 

        // if user is X, filter steps
        $current_user = wp_get_current_user();
        $current_user_id = $current_user->ID;

        if ($current_user_id == 123) {
            // Entries for these Step ID's should be displayed for this user
            $step_search_criteria['field_filters'][] = array( 'key' => 'workflow_step', 'operator' => 'in', 'value' => array('267','368', '516')); 
            $search_criteria = $step_search_criteria;
        }
    }

    return $search_criteria;
}