Skip to content

Instantly share code, notes, and snippets.

@jwahlin
Last active October 23, 2019 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jwahlin/a7944fb071f254755264da746842e46e to your computer and use it in GitHub Desktop.
Save jwahlin/a7944fb071f254755264da746842e46e to your computer and use it in GitHub Desktop.
Combine Formidable stats with SKT Skillset shortcode
add_shortcode( 'custom_progress_bar', 'add_custom_progress_bar' );
function add_custom_progress_bar( $atts ) {
if (
! isset( $atts['user'] ) || ! isset( $atts['goal'] ) || ! isset( $atts['year_month'] )
|| ! isset( $atts['title'] ) || ! isset( $atts['goal_id'] )
) {
return '';
}
// Get total amount completed for the current month
$amount_complete = FrmProStatisticsController::stats_shortcode(
array(
'id' => 40206,//Replace 40206 with the ID of the field you want to total
'type' => 'total',
'user_id' => $atts['user'],
'40204_greater_than_or_equal_to' => $atts['year_month'] . '-01',// Replace 40204 with the ID of the date field in your log activity form
'40204_less_than_or_equal_to' => $atts['year_month'] . '-31',// Replace 40204 with the ID of the date field in your log activity form
'40205' => $atts['goal_id'],// Replace 40205 with the ID of the hidden field or Dynamic field that stores the goal entry ID
)
);
// Divide by goal
$percent = ( (int) $amount_complete / (int) $atts['goal'] ) * 100;
return do_shortcode( '[skill title_background="#2f97ac" bar_foreground="#21b7c4" bar_background="#eeeeee" percent="' .
$percent . '" title="' . $atts['title'] . '"]' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment