Support

Account

Home Forums General Issues Connecting users with list of information

Unread

Connecting users with list of information

  • On our site, Users shall create a list of destinations they like to receive a deal alert. New posts are associated with destinations as well and when a new post is published, all users that added that destination to their list shall receive a notification.

    I implemented that by creating a custom taxonomy “destination” and a custom field for both users and posts where they can select the destinations they find interesting. Though I am having issues with the final implementation and would like to have your feedback if there is a smarter way to do this.

    Right now, we the users adds a destination to his list in our frontend which starts an ajax request to this backend code:

    $deal_alert = get_field('deal_alert', wp_get_current_user());
    $travel_destination_id = intval($_POST['travel_destination_id']);
    array_push($deal_alert, $travel_destination_id);
    update_field('deal_alert', $deal_alert, wp_get_current_user());

    This does the job and the data is saved to the usermeta-table with

    a:2:{i:0;i:532;i:1;i:523;}

    Though when I want to query for users that are associated with taxonomy 5 or 4, it would like this:

    'meta_query' => array(
        array(
            'key' => 'deal_alert',
            'value' => '4',
            'compare' =>  'LIKE'
        ),
        array(
            'key' => 'deal_alert',
            'value' => '5',
            'compare' =>  'LIKE'
        )
    )

    And will return also the user which has the taxonomy with id 524 selected.

    What am I doing wrong? How should I implement this properly that a) both posts and users have a list of destinations and b) there is an efficient way to query the few out of 1.000+ users that have selected certain taxonomies?

    I highly appreciate your feedback, our project is close to deadline and I am not sure how to do this 😉

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.