AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

Filter by custom fields

Topic prefix

AI Assistant
Notifications
Clear all

[Solved] Show Only One Group to Guests

3 Posts
2 Users
2 Reactions
486 Views
Danno6116
Posts: 83
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@danno6116)
Estimable Member
Joined: 2 years ago
[#72711]

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,


2 Replies
Robert
Posts: 10716
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@robert)
Support Team
Joined: 2 months ago

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

 


Reply
Danno6116
Posts: 83
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@danno6116)
Estimable Member
Joined: 2 years ago

@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


Reply
Share: