should be doable, so :
1 topic per week, and any no. replies?
1 topic and one reply per week?
I topic or reply per week?
etc?
oh, and just participants? ie Keymaster and moderators can post as many as they like?
Hey Robin,
Thanks for answering.
I was thinking:
1 new topic per month.
Any number of replies
Only applies to participants’ user role
Would that be possible?
Thank you
This code should do it
add_filter ('bbp_current_user_can_access_create_topic_form' , 'rew_only_one_topic', 10 , 1) ;
add_filter( 'gettext', 'rew_change_text', 20, 3 );
function rew_only_one_topic ($retval) {
//first check if they have access, only amend if they have
if ($retval==true) {
$user_id = wp_get_current_user()->ID;
$role = bbp_get_user_role( $user_id );
if ($role == 'bbp_participant') {
$last_posted = bbp_get_user_last_posted( $user_id );
if (time() <($last_posted + (60*60*24*31))) $retval = false ;
}
}
return $retval ;
}
function rew_change_text($translated_text, $text, $domain ) {
if ( $text == 'You cannot create new topics.') {
$user_id = wp_get_current_user()->ID;
$role = bbp_get_user_role( $user_id );
if ($role == 'bbp_participant') {
$last_posted = bbp_get_user_last_posted( $user_id );
if (time() <($last_posted + (60*60*24*31))) {
$translated_text = 'You cannot post a new topic - you have already posted a topic in the last month';
}
}
}
return $translated_text;
}
The 60*60*24*31 is 60 seconds, 60 minutes, 24 hours, 31 days, so you can change this to whatever you want in both places.
and you can change $translated_text = ‘You cannot post a new topic – you have already posted a topic in the last month’ to whatever phrase in whatever language you want.
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
Legend, thank you. I can’t wait to give this a try! 🙂