Skip to:
Content
Pages
Categories
Search
Top
Bottom

Members meta query

  • @janismo

    Participant

    hi,

    I’m trying to get IDs of members, who have specific activity as a favorite.
    Issue is that I cannot get how to query specific activity, e.g. how to get activity with an id 900 from the line a:2:{i:3;i:883;i:8;i:900;}? Any help? thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • @shanebp

    Moderator

    @janismo

    Participant

    thanks, shanebp, however, cannot say that I understood your idea. Will explain from a different angle. I have an activity ID ‘900’ and 10 users. How do I get IDs of the users, who has activity 900 as a favorite?

    @shanebp

    Moderator

    Favorites are stored per user in wp_usermeta in a serialized string in meta_value.

    If they were stored per activity, what you need would be easy.

    You could try: `global $wpdb;
    $fav_ids = $wpdb->get_col(

    SELECT user_id FROM wp_usermeta
    WHERE meta_key LIKE ‘bp_favorite_activities’
    AND meta_value LIKE ‘%\”900\”%’

    ); `

    But this approach may return false matches.

    https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Column

    @janismo

    Participant

    thanks shanebp, found the same solution, probably, should work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Members meta query’ is closed to new replies.
Skip to toolbar