I have a site that is using formidable to create a post, but would like to have a control on the number of posts a registered user can create based on their role. Is there a way to do that with formidable?
There are plugins available for the back-end, but I would like to use this functionality on the front-end.




August 23, 2012 at 3:18 pm
This can be done with some custom code. Here are some basic examples that would require expanding for a user-role specific limit.
http://formidablepro.com/knowledgebase/frm_display_form_action/
August 23, 2012 at 3:51 pm
Thanks for the info - it's very close to what I need. Can i add one more variable, based on user role per month?
For example:
Role1 = 5 posts per month
Role2 = 10 posts per month
August 24, 2012 at 10:34 am
Yes, you can, but you will need to complete it on your own. Replace if($count >= 10){ with something like
$allowed = 5;
if(current_user_can('author')
$allowed = 10;
if($count >= $allowed){
August 24, 2012 at 10:51 am
Thank you Stephanie! This works great, I'll just need to write a new function for each of the roles I would like to limit.
I've also changed the date to just the month - hopefully this will allow the user with this role to be able to post 10 new posts every month??
This is the code i'm using:
/// LIMIT POSTS BASED ON ROLE
add_action('frm_display_form_action', 'check_entry_count', 8, 3);
function check_entry_count($params, $fields, $form){
global $user_ID;
if($form->id == 17 and !is_admin()){ //replace 5 with your form ID
$count = FrmEntry::getRecordCount("it.created_at > '". gmdate('m')." 00:00:00' and user_id=".$user_ID);
if(current_user_can('editor'))
$allowed = 10;
if($count >= $allowed){
echo 'You have reached your limit for the month.';
add_filter('frm_continue_to_new', create_function('', 'return false;'), 50);
}
}
}
August 24, 2012 at 11:02 am
gmdate('m')." 00:00:00' won't do what you want. The date format can't change if you want it to work.
gmdate('Y-m')."-01 00:00:00'
August 24, 2012 at 11:10 am
Thanks, I'll implement it.
Topic closed.