Skip to:
Content
Pages
Categories
Search
Top
Bottom

filter option: groups I created only

  • @alvin341965

    Participant

    this is a must in the groups plugin people.
    have an option to see only the groups i created. or at least a filter option!!

    If this already exists please show me where please!!
    version WP & BP current production version

Viewing 2 replies - 1 through 2 (of 2 total)
  • @henrywright

    Moderator

    Hi @alvin341965,

    There’s a function that will help you do that. It’s called groups_is_user_creator(). The first step is to create a groups loop. The code on this page will do that for you. Then immediately after <?php while ( bp_groups() ) : bp_the_group(); ?> you could add something like this:

    if ( ! groups_is_user_creator( bp_loggedin_user_id(), bp_get_group_id() ) )
        continue;

    Some considerations:

    • I’ve used bp_loggedin_user_id(), but feel free to use something else like the displayed member’s ID.
    • The function uses BP_Groups_Member::check_is_creator() which performs a database query for each item in the loop. To improve performance you might want to write your own SQL targeting groups only you’ve created and then loop through the result set. There may already be a function that does that for you. I’m not aware of one but someone else on here might be
    • This doesn’t work well with pagination

    @alvin341965

    Participant

    Henry, thank you so much. This is exactly what i needed.
    i have been going thru the code for two days …
    Can i use this for the counter function also at profile group icon?

    again thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘filter option: groups I created only’ is closed to new replies.
Skip to toolbar