If you just need a quick and dirty approach for yourself to view, you could use the standard group loop to output a loop. See here.
Then put the following snippet directly after the line: <?php while ( bp_groups() ) : bp_the_group(); ?>
Snippet:
<?php
$args = array(
'populate_extras' => true,
'group_id => bp_get_group_id()
);
$group = groups_get_group( $args );
if ( ! in_array( bp_loggedin_user_id(), $group->admins ) ) {
continue;
}
?>
Notes:
- I haven’t tested
- This approach won’t be performant
- I haven’t considered pagination
That said, it should get the job done. The alternative is to write some SQL and use the wpdb class.
There is a BP function for getting the ids of the groups for which you’re an admin: get_is_admin_of
You could use it like this:
function my_group_admin_ids() {
$my_group_ids = BP_Groups_Member::get_is_admin_of( 1 ); //if your id = 1
foreach( $my_group_ids['groups'] as $group ) {
$link = bp_get_group_permalink( $group );
echo '<a href="' . $link .'">' . $group->name . '</a><br/>';
}
}
add_action( 'bp_before_directory_groups', 'my_group_admin_ids');
If you want to create a custom tab to hold that info, you need to create a new li element in a template overload of this file:
\bp-templates\bp-legacy\buddypress\groups\index.php
Thanks for the help ill try these
@mattsten don’t bother with my solution; @shanebp’s is far better!
I want this too.
on my profile i only wanna see my groups where i am admin of and not all of them i am member of!
what file(s) should I edit?
i run the latest version of BP and WP.
kind regards
Just put @shanebp’s code in your theme’s functions.php file.
thank you that works.
But i need something else to work on my profile page.
when you click groups on profile tab i want only my own groups that i created to show and not the ones that i am a member of. Where do i put the filter in php
kind regards
@alvin341965 That’s quite different so you should open a different topic for that 🙂
ok sorry for that…
new to this forum 🙁
will create a new topic
thank you
No worries; welcome to the forum! 🙂