Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Automatically create a category for each user that submits a review
- * This category can then be used to target the user reviews
- * i.e. [site_reviews category=u_13] - u_13 is the category slug for the author with an user ID of 13
- * @param \GeminiLabs\SiteReviews\Review $review
- * @return void
- */
- add_action('site-reviews/review/created', function ($review) {
- if ($user = get_userdata($review->user_id)) {
- $term = 'u_'.$user->ID;
- $taxonomy = glsr()->taxonomy;
- if (!term_exists($term, $taxonomy)) {
- wp_insert_term($user->display_name, $taxonomy, ['slug' => $term]);
- }
- wp_set_object_terms($review->ID, $term, $taxonomy);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement