Hello everyone.,
My platform uses wpForo with the Custom User Fields plugin. I need visitors (not logged in) to see only one specific group and its member cards when they land on the site, while the rest of the global member database remains hidden until login.
Because the member database is global, I’ve spent hours trying different methods and even tested-added a second board without success.
Can anyone provide guidance on how to restrict all other groups and member cards until after login, while allowing public visibility to just this one group?
Thank you,
Hi @danno6116
The best approach is to use the wpforo_current_object_members_args_filter hook to restrict which usergroups guests can see.
Here is a code snippet you can try. Put it in Code Snippets plugin (PHP) or directly in the current active functions.php file. Change th 5 to any user group ID you want. If they are multiple, you can separate them by comma [5, 6, 7]:
/**
* Restrict member list visibility for guests to a single usergroup
*
* @param array $args Member query arguments
* @param array $get GET parameters
* @return array Modified arguments
*/
add_filter( 'wpforo_current_object_members_args_filter', function( $args, $get ) {
// Only apply to guests (not logged in users)
if( empty( WPF()->current_userid ) ) {
// Replace 5 with YOUR target usergroup ID that guests should see
$args['groupids'] = [ 5 ];
}
return $args;
}, 10, 2 );
@robert Thank you very much Sir It is very Appreciated! Seems to work very well if I have any issues I'll let you know but thank you