Created
September 11, 2018 00:51
-
-
Save Idealien/678605e668a64812679ed8f524a34e6e to your computer and use it in GitHub Desktop.
Core pieces to get assignee info into Gravity Flow status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'gravityflow_columns_status_table', 'custom_column_titles', 10, 3 ); | |
function custom_column_titles( $columns, $args, $table ) { | |
$new_column = array( | |
'assignees' => 'Assignee(s)', | |
); | |
$pre_columns = array_slice( $columns, 0, 2 ); | |
$post_columns = array_slice( $columns, 2 ); | |
$columns = array_merge( $pre_columns, $new_column, $post_columns ); | |
return $columns; | |
} | |
add_filter( 'gravityflow_field_value_status_table', 'custom_column_field_values', 10, 4 ); | |
function custom_column_field_values( $value, $form_id, $column_name, $entry ) { | |
if ( $column_name == 'assignees' ) { | |
$api = new Gravity_Flow_API( $form_id ); | |
$step = $api->get_current_step( $entry ); | |
if( $step !== false ) { | |
$assignees = $step->get_assignees(); | |
if ( $assignees ) { | |
foreach( $assignees as $assignee) { | |
if( $assignee->get_type() === 'user_id' ) { | |
$value .= "<ul>"; | |
$value .= "<li><strong>KEY</strong>: " . $assignee->get_key() . '</li>'; | |
$value .= "<li><strong>TYPE</strong>: " . $assignee->get_type() . '</li>'; | |
$value .= "</ul>"; | |
} | |
} | |
} | |
} | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment