Notifications
Clear all

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

4 Posts
2 Users
0 Likes
780 Views
hill-seeker91
Posts: 17
Topic starter
(@hill-seeker91)
Active Member
Joined: 3 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.

 

Topic Tags
3 Replies
Sofy
Posts: 4057
 Sofy
Admin
(@sofy)
Support Team
Joined: 5 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;
});
Reply
2 Replies
hill-seeker91
(@hill-seeker91)
Joined: 3 years ago

Active Member
Posts: 17

@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

 

Reply
Sofy
 Sofy
Admin
(@sofy)
Joined: 5 years ago

Support Team
Posts: 4057

@hill-seeker91,

the thread is opened. 

 

Reply
Share: