Notifications
Clear all

wpForo 1.x.x [Closed] Redirect non-logged in user to login page

4 Posts
2 Users
0 Reactions
1,198 Views
hill-seeker91
Posts: 20
Topic starter
(@hill-seeker91)
Eminent Member
Joined: 4 years ago

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: 4421
 Sofy
Admin
(@sofy)
Support Team
Joined: 6 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: 4 years ago

Eminent Member
Posts: 20

@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: 6 years ago

Support Team
Posts: 4421

@hill-seeker91,

the thread is opened.