Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get Group IDs of current_user and related post-categories of groups

  • @thomasklosinsky

    Participant

    Hi there,

    I want to show the posts of group related categories on the user profile when logged in.
    Any idea how to implement?

    I have these two functions in mind but don’t know how to use them further:

    $groups = BP_Groups_Member::get_group_ids(bp_loggedin_user_id());
    $category_ids = bcg_get_categories($groups);

    I appreciate every help!

    Best regards,
    Thomas

Viewing 1 replies (of 1 total)
  • @thomasklosinsky

    Participant

    for everyone who needs it too:

    $user_id = bp_loggedin_user_id();
    $group_ids = $wpdb->get_col($wpdb->prepare(“SELECT group_id FROM {$wpdb->prefix}bp_groups_members WHERE user_id = %d”,$user_id),0);
    foreach ($group_ids as $group_id )
    {
    $category_ids .= “,”.implode(bcg_get_categories($group_id));
    };
    $category_ids = substr($category_ids, 1);

    That’s all.

    Add query_posts(“cat=$category_ids”); and you are good to go.

Viewing 1 replies (of 1 total)
  • The topic ‘Get Group IDs of current_user and related post-categories of groups’ is closed to new replies.
Skip to toolbar