Where and when you place the data is up to you.
To gather the data, try :
$args = array(
'show_hidden' => true,
'per_page' => -1
);
$groups = groups_get_groups( $args );
foreach ( $groups['groups'] as $group ) {
$args = array(
'group_id' => $group->id,
'exclude_admins_mods' => false
);
$members = groups_get_group_members( $args );
echo'<pre>'; var_dump( $members ); echo'</pre>'; // just for reference
// do something with the member data
}
Hello shanebp, thank you very much for your response:
We have realized that users could not access the home page of other private groups due to the inteference of another active plugin. Deactivating it, users already have access to the home page of others private groups, but still can not see the list of members of those groups. I’ve been trying to use your code (in function.php and writing it as html text), but it does not work, possibly I’m not writing it in the right place. Do you know how to solve this problem, please??
Thank you very much for your help.
Hello @shanebp, thanks for the hook.
Sorry but I don`t know where I have to insert it. Wherever I paste it, no group members list is displayed (probably I’m not pasting it it in the correct file), I have tried in functions.php and in group-header.php of the theme. Could you please tell me where I should insert it?
Thank you and sorry for bothering.
As stated, the code is just an example of collecting the groups and group members.
You could put the code in a function and then call that function wherever you want.
For example, this could go in your theme > functions.php file :
function diego_show_groups() {
$args = array(
'show_hidden' => true,
'per_page' => -1
);
$groups = groups_get_groups( $args );
foreach ( $groups['groups'] as $group ) {
$args = array(
'group_id' => $group->id,
'exclude_admins_mods' => false
);
$members = groups_get_group_members( $args );
echo'<pre>'; var_dump( $members ); echo'</pre>'; // just for reference
// do something with the member data
}
}
Then in a template, you could put: <?php diego_show_groups(); ?>
Only you know exactly what you’re trying to do.
As I said: Where and when you place the data is up to you.
Thank you for your help @shanebp.
Data are collected, but I couldn´t be able to get a structured list of the groups members.
Thanks again. Regards.