-
-
Save bryanwillis/b26e52f78b24359854917d1ba5885193 to your computer and use it in GitHub Desktop.
Combine Formidable stats with SKT Skillset shortcode
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
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
I created a View from the "Set a goal" form. I used this shortcode in my View:
40914 is the ID of my repeating section
40197 is the ID of the "activity" field
40196 is the ID of the goal number/amount
40200 is the ID of the userID field
40210 is the ID of a "Year" dropdown (outside of repeating section)
40193 is the ID of a "Month" dropdown (outside of repeating section)