Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('admin_init', function () {
- if (!function_exists('glsr_get_reviews')) {
- return;
- }
- if (!function_exists('glsr_update_review')) {
- return;
- }
- $reviews = glsr_get_reviews([
- 'per_page' => -1,
- ]);
- foreach ($reviews as $review) {
- if (empty($review->author_id)) {
- error_log("🟠Skipped review ID {$review->ID}: No author found");
- continue;
- }
- if (!empty($review->assigned_users)) {
- error_log("🟠Skipped review ID {$review->ID}: Already has assigned user");
- continue;
- }
- $result = glsr_update_review($review->ID, [
- 'assigned_users' => $review->author_id,
- ]);
- if (false === $result) {
- error_log("🔴 Skipped review ID {$review->ID}: Update failed");
- continue;
- }
- error_log("🟢 Assigned {$review->author_id} to review ID {$review->ID}");
- }
- error_log("✅ Finished assigning users to reviews");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement