Advertisement
geminilabs

Untitled

Apr 29th, 2025 (edited)
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. add_action('admin_init', function () {
  2.     if (!function_exists('glsr_get_reviews')) {
  3.         return;
  4.     }
  5.     if (!function_exists('glsr_update_review')) {
  6.         return;
  7.     }
  8.     $reviews = glsr_get_reviews([
  9.         'per_page' => -1,
  10.     ]);
  11.     foreach ($reviews as $review) {
  12.         if (empty($review->author_id)) {
  13.             error_log("🟠 Skipped review ID {$review->ID}: No author found");
  14.             continue;
  15.         }
  16.         if (!empty($review->assigned_users)) {
  17.             error_log("🟠 Skipped review ID {$review->ID}: Already has assigned user");
  18.             continue;
  19.         }
  20.         $result = glsr_update_review($review->ID, [
  21.             'assigned_users' => $review->author_id,
  22.         ]);
  23.         if (false === $result) {
  24.             error_log("🔴 Skipped review ID {$review->ID}: Update failed");
  25.             continue;
  26.         }
  27.         error_log("🟢 Assigned {$review->author_id} to review ID {$review->ID}");
  28.     }
  29.     error_log("✅ Finished assigning users to reviews");
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement