Created
January 6, 2023 15:06
-
-
Save vfontjr/acd04d98880b674cfc4bc0cee58d327c to your computer and use it in GitHub Desktop.
Count All Fom Entries
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_shortcode('count_form_entries', 'count_form_entries_callback'); | |
function count_form_entries_callback( $atts ) { | |
$count = 0; | |
if ( !empty( $atts ) ) { | |
$atts = shortcode_atts( array( | |
'frm_id' => '0', | |
'frm_key' => '' | |
), $atts, 'count_form_entries' ); | |
if ( isset($atts['frm_id']) && !empty($atts['frm_id']) && $atts['frm_id'] !== '0' ) { | |
$id = $atts['frm_id']; | |
} elseif ( isset($atts['frm_key']) && !empty($atts['frm_key']) && $atts['frm_key'] !== '0' ) { | |
$id = FrmForm::get_id_by_key( $atts['frm_key'] ); | |
} | |
$count = FrmEntry::getRecordCount("form_id=". $id); | |
} | |
return $count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment