Jake Vanderwerf
2026-02-04 2127b1bdd73ecd2423e443992da4b442f5a3c1a3
inc/helpers/members.php
@@ -1,7 +1,7 @@
<?php
use JVBase\managers\CacheManager;
use JVBase\meta\MetaManager;
use JVBase\managers\Cache;
use JVBase\meta\Meta;
if (!defined('ABSPATH')) {
   exit;
@@ -16,16 +16,14 @@
 */
function jvbShareName(int $userID):string
{
    $cache = CacheManager::for('usernames');
    $cached = $cache->get($userID);
    if ($cached) {
        return $cached;
    }
    $check = get_user_meta($userID, BASE.'notify', true);
    $name = ($check) ? get_userdata($userID)->display_name : 'Someone';
    $cache->set($userID, $name);
    return $name;
    $cache = Cache::for('usernames')->connect('user');
   return $cache->remember(
      $userID,
      function() use ($userID) {
         $check = get_user_meta($userID, BASE.'notify', true);
         return ($check) ? get_userdata($userID)->display_name : 'Someone';
      }
   );
}
/**
@@ -35,38 +33,37 @@
 */
function jvbGetUserByFirstName(string $first_name):WP_User|false
{
    $cache = CacheManager::for('userFirstname')->connectTo('user');
    $cached = $cache->get($first_name)??false;
    if ($cached) {
        return get_userdata($cached);
    }
    $args = [
        'post_type' => BASE . 'artist',
        'posts_per_page' => 1,
        'fields' => 'ids',
        'meta_query' => [
            [
                'key' => BASE . 'first_name',
                'value' => $first_name,
                'compare' => '='
            ]
        ]
    ];
    $cache = Cache::for('userFirstname')->connect('user', true);
   return $cache->remember(
      $first_name,
      function() use ($first_name) {
         $args = [
            'post_type' => BASE . 'artist',
            'posts_per_page' => 1,
            'fields' => 'ids',
            'meta_query' => [
               [
                  'key' => BASE . 'first_name',
                  'value' => $first_name,
                  'compare' => '='
               ]
            ]
         ];
         $query = new WP_Query($args);
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        $post_id = $query->posts[0];
        $user_id = get_post_meta($post_id, BASE . 'link', true);
        $user = get_userdata($user_id)?:false;
        $cached[$user_id] = $first_name;
        $cache->set('user_first_names', $cached);
      wp_reset_postdata();
        return $user;
    }
   wp_reset_postdata();
    return false;
         if ($query->have_posts()) {
            $post_id = $query->posts[0];
            $user_id = get_post_meta($post_id, BASE . 'link', true);
            $user = get_userdata($user_id)?:false;
            if ($user) {
               wp_reset_postdata();
               return $user;
            }
         }
         wp_reset_postdata();
         return false;
      }
   );
}
/**
@@ -76,7 +73,7 @@
 */
function jvbGetUserByDisplayName(string $display_name):WP_User|false
{
    $cache = CacheManager::for('user_displaynames')->connectTo('user');
    $cache = Cache::for('displayNames')->connect('user', true);
    $cached = $cache->get($display_name)??false;
    if ($cached && is_int($cached)) {
@@ -115,7 +112,7 @@
function jvbGetUsername(int $user_id):string
{
    $key = 'user_display_names';
    $cache = CacheManager::for('userNames', WEEK_IN_SECONDS)->connectTo('user');
    $cache = Cache::for('userNames', WEEK_IN_SECONDS)->connect('user');
    $cached = $cache->get($user_id);
    if ($cached) {
@@ -156,7 +153,7 @@
        return false;
    }
    $cache = CacheManager::for('artist', 3600)->connectTo('post');
    $cache = Cache::for('artist', 3600)->connect('post');
   $cached = $cache->get($userID);
   if ($cached) {
      return match ($return) {
@@ -177,7 +174,7 @@
    }
    $id = (int) get_user_meta($userID, BASE.'link', true);
   $meta = new MetaManager($id,'post');
   $meta = Meta::forPost($id);
   $artist = $meta->getAll(['first_name','type','city','shop']);
   $artist['id'] = $id;
   $artist['display_name'] = $user->display_name;
@@ -212,7 +209,6 @@
      return 'admin';
   }
    $user = ($ID === 0) ? wp_get_current_user() : get_userdata($ID);
   error_log('Current User: '.print_r($user, true));
    return array_values(array_intersect(
        array_keys(array_merge(JVB_USER, ['administrator'])),
        array_map(function ($role) {