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
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