Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.