Categories
WooCommerce Extensions

User Posts Limit

How to make some user unrestricted in rules that applied on certain post type?
Update the user id and the post type:

add_filter( 'upl_query', 'upl_unrestrict_user' );
function upl_unrestrict_user( $args ) {
	$post_type = 'post';
	$user_id = 12;
	if ( $post_type === $args['post_type'] && $user_id === $args['author'] ) {
		$args['post_type'] = 'none';
	}
	return $args;
}

How to make rules that applied on certain post type to limit the total posts in the website?
Update the post type:

add_filter( 'upl_query', 'upl_limit_total_posts' );
function upl_limit_total_posts( $args ) {
	$post_type = 'post';
	if ( $post_type === $args['post_type'] ) {
		$args['author'] = '';
	}
	return $args;
}

How to make rules that applied on certain post type to limit by posts in specific category only?
Update the post type and the category id (make sure users can’t modify posts category):

add_filter( 'upl_query', 'upl_specific_category' );
function upl_specific_category( $args ) {
	$post_type = 'post';
	$category_id = 4;
	if ( $post_type === $args['post_type'] ) {
		$args['cat'] = $category_id;
	}
	return $args;
}

How to make rules that applied on certain post type to limit specific post status?
Update the post type and the post status (make sure users can’t modify post status):

add_filter( 'upl_query', 'upl_specific_post_status' );
function upl_specific_post_status( $args ) {
	$post_type = 'post';
	$post_status = [ 'any' ];
	if ( $post_type === $args['post_type'] ) {
		$args['post_status'] = $post_status;
	}
	return $args;
}

How to modify the cycle for rules that applied on certain post type?
Update the post type and the cycle (keep in mind that the change will not take affect in places that the date is displayed):

add_filter( 'upl_query', 'upl_modify_cycle' );
function upl_modify_cycle( $args ) {
	$post_type = 'post';
	$cycle = '3 days ago';
	if ( $post_type === $args['post_type'] ) {
		$args['date_query']['after'] = $cycle;
	}
	return $args;
}

How to send users an Email to encourage them to upgrade their membership after they try to post after posts limit exceeded?
Attach your code for sending Email to the upl_limit_applied action hook.

How to define different message types for each user?
Use the upl_message and upl_notice filters.

Leave a Reply

Your email address will not be published. Required fields are marked *