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

[Closed] Redirect non-logged in user to login page

4 Posts
2 Users
0 Reactions
2,107 Views
hill-seeker91
Posts: 22
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
(@hill-seeker91)
Eminent Member
Joined: 6 years ago
[#12599]

Hi I'm just experimenting with setting up wpforo on a new site with a private forum.

While wpForo seems to hide topics and posts from non-logged in users, it would be nice if there was a setting to simply redirect anyone trying to access the forum who isn't logged in to the login page. (Easier user experience for members to work out that's what they've forgotten to do, and more secure that it doesn't show there is a valid forum board with that name)

Is this possible? If so, how do I do it? Thanks.

 


3 Replies
Sofy
Posts: 5774
 Sofy
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
(@sofy)
Support Team
Joined: 8 years ago

Hi @hill-seeker91,

Please put the following code in your current active theme functions.php file:

 
add_filter('wpforo_after_init_current_object', function ($current_object){
    if( in_array($current_object['template'], array('forum', 'topic')) ){
        if( !WPF()->current_userid && !WPF()->perm->forum_can('vf', $current_object['forumid']) ){
	        wp_redirect( wpforo_login_url() );
	        exit();
        }
    }
    return $current_object;
});

2 Replies
hill-seeker91
(@hill-seeker91)
Joined: 6 years ago

Eminent Member
Posts: 22
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

@sofy Thanks I'll try that. 

Spoke a bit too soon on the other thread (and can't now post as you've closed it!) Can you reopen that so I can add a post please as although it's a great workaround there is an underlying issue which probably ought to be resolved in a future release. Thanks

 


Sofy
 Sofy
Admin
(@sofy)
Joined: 8 years ago

Support Team
Posts: 5774
Sofy
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

@hill-seeker91,

The thread is open. 

 


Share: