Set a maximum upload count for users on a specific user role

For users with the Contributor user role, I want to restrict the total amount of images that they are allowed to upload. I found this code posted on an answer here: add_filter( ‘wp_handle_upload’, ‘wpse47580_update_upload_stats’ ); function wpse47580_update_upload_stats( $args ) { $user_id = get_current_user_id(); $upload_count = get_user_meta( $user_id, ‘upload_count’, $single = true ); update_user_meta( $user_id, ‘upload_count’, … Read more

How can I limit the number of comments per registered user per day?

I found this code on WPSE: global $current_user, $post; $args = array( ‘user_id’ => $current_user->ID, ‘post_id’ => $post->ID ); $usercomment = get_comments( $args ); if ( 1 <= count( $usercomment ) ) { echo ‘disabled’; } else { comment_form(); } Note: It seems to limit the number of comments per post per user. I want … Read more