Changeset 5605
- Timestamp:
- 06/29/2017 09:32:41 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
r4144 r5605 15 15 // Custom user contact methods. 16 16 add_filter( 'user_contactmethods', array( $this, 'custom_contact_methods' ) ); 17 18 // Only allow 3 published topics from a user in the first 24 hours. 19 add_action( 'bbp_new_topic_pre_insert', array( $this, 'limit_new_user_topics' ) ); 17 20 } 18 21 … … 63 66 } 64 67 68 /** 69 * Only allow 3 published topics from a user in the first 24 hours. 70 * 71 * If the user has exceeded their limit, move any new topics to moderation queue. 72 * 73 * @param array $topic_data Topic data. 74 * @return array Filtered topic data. 75 */ 76 public function limit_new_user_topics( $topic_data ) { 77 $current_user = wp_get_current_user(); 78 79 if ( time() - strtotime( $current_user->user_registered ) >= DAY_IN_SECONDS ) { 80 return $topic_data; 81 } 82 83 if ( 'publish' === $topic_data['post_status'] && bbp_get_user_topic_count_raw( $current_user->ID ) >= 3 ) { 84 $topic_data['post_status'] = 'pending'; 85 } 86 87 return $topic_data; 88 } 89 65 90 }
Note: See TracChangeset
for help on using the changeset viewer.