每个角色的职位数限制[关闭]

问题描述 投票:0回答:1
嗨,我想限制每个角色的职位,我已经尝试了一些插件,但是它们似乎没有用我希望当角色中的用户达到10个限制时,如果您尝试添加新帖子,我将弹出一个对话框,说他们已达到其帖子限制
wordpress limit posting
1个回答
0
投票
您可以使用此插件Posts Creation Limits,该插件具有每个用户,每个角色,每个帖子类型,每个帖子状态限制系统,并与其post_creation_limits_custom_checks动作挂钩结合使用,并检查用户是否当天已经创建了帖子-如果是这样:显示“已达到极限消息”。例如:

add_action( 'post_creation_limits_custom_checks', 'post_per_day_limit' ); function post_per_day_limit( $type, $user_id ) { global $bapl,$wpdb; // safe check: Plugin installed? ! isset( $bapl ) AND _doing_it_wrong( __FUNCTION__, sprintf( 'You need to %sinstall the needed Plugin%s', '<a href="http://wordpress.org/extend/plugins/bainternet-posts-creation-limits/">', '</a>' ), 0 ); $time_in_days = 1; // 1 means in last day $count = $wpdb->get_var( $wpdb->prepare(" SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = %s AND post_author = %s AND post_date >= DATE_SUB(CURDATE(),INTERVAL %s DAY)", $type, $user_id, $time_in_days ) ); if ( 0 < $count ) $count = number_format( $count ); // here you can check since we have the $count ex: // limit for 2 posts a day if ( 1 < $count ) { // return limit reached message using the plugin class exit( $bapl->bapl_not_allowed( 'you can not posts more them two posts a day' ) ); } // else do nothing }

© www.soinside.com 2019 - 2024. All rights reserved.