Custom Fields
Support MB User Meta User query for timestamp in meta array whne less than today's date

  • Creator
  • #26558
    Resolved rubbergumball

    I've given access to content my site by adding meta values to user data using the MB User Meta. The data I need to access is a timestamp, one of two items in an array for that user (the other is the product) and they can have multiple products with different timestamps. Timestamps are used to determine when access is removed.

    How would I query and return the timestamp for all users if timestamp is less than today? I would like to remove access if the timestamp is less than today.

    this is an example of the data stored in Database for the meta field "product_data":

    this is my current code to return the users but it doesn't return any results:

    $date = new DateTime();
    $theDate = $date->getTimestamp();
    $user_query = new WP_User_Query( 
            'product_data' => 'acc_expiry_date', 
            'meta_value' => '$theDate', 
            'meta_compare' => '<' 
    // The User Query
    $user_query = new WP_User_Query( $args );
    // The User Loop
    if ( ! empty( $user_query->results ) ) {
        foreach ( $user_query->results as $user ) {
            // change meta go here after success test
            $user_info = get_userdata($user->ID);
            echo '<li>' . $user_info->first_name . ' ' . $user_info->last_name . '</li>';
    } else {
        // no users found


Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.