Created
January 4, 2023 12:25
-
-
Save vfontjr/5d072ab98c24568ca3a1ab9a690ef3ed to your computer and use it in GitHub Desktop.
Count Formidable Entries by User Role
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_action('frm_display_form_action', 'check_entry_count', 8, 3); | |
function check_entry_count($params, $fields, $form) { | |
global $user_ID; | |
/* get the current user object */ | |
$current_user = wp_get_current_user(); | |
remove_filter('frm_continue_to_new', '__return_false', 50); | |
if( $form->id == 5 and !is_admin() ) { //replace 5 with the ID of your form | |
$count = FrmEntry::getRecordCount("form_id=". $form->id ." AND user_id=".$user_ID); | |
if ( ( in_array('public', $current_user->roles) && $count >= 50 ) || ( in_array('business', $current_user->roles) && $count >= 100 ) ) { | |
echo 'This form is closed'; | |
add_filter('frm_continue_to_new', '__return_false', 50); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment