How to only give access if logged into Wordpress?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
t0rxe
Registered User
Posts: 6
Joined: Thu Dec 10, 2020 2:23 pm

How to only give access if logged into Wordpress?

Post by t0rxe »

Hi,

I have a phpBB forum setup and I'd like only users on my Wordpress site who are logged in on it to have access to the forums. The way in which you do that under Wordpress you can run a PHP function like 'is_user_logged_in()' which will return TRUE or FALSE. How can this be done under phpBB?

At the moment, I just have my forums in an iframe. This works, but it's open to the public (which I don't want).

Code: Select all

<iframe src="http://mysite.com/forum"
onload=\'javascript:(function(o){o.style.height=o.contentWindow.document.body.scrollHeight+"px";}(this));\'
style="height:100%; width:100%; border:none; overflow:hidden; frameborder="0" scrolling="no">
</iframe>
The reason for this is I only want genuine users who have bought something from my store (since when they buy something Wordpress makes an account for them) to have access to the forums. One trick I thought of is to use a plugin like 'WP w3all phpBB' and have it automatically create account for new users, but the problem with that is I already have genuine users on phpBB and I can't just delete the existing accounts and their topics, so checking if they are simply logged in is a better solution in my case.

If anyone has any suggestions or ideas, that would be great.

Thanks.
User avatar
miroslavglavic
Registered User
Posts: 73
Joined: Sat Feb 28, 2009 5:28 pm
Location: Toronto, Canada
Name: Miroslav Glavić
Contact:

Re: How to only give access if logged into Wordpress?

Post by miroslavglavic »

I have seen a bridge between WordPress and PHPbb. It's been a while since I seen it.

You are going to have to maintain two user databases. Somehow bridge them together.

Wouldn't it be easier for visitors to just log in on the PHPbb side only?

Somehow you will have to bring the wp login session onto PHPbb.
New Signature coming soon
jongore
Registered User
Posts: 1
Joined: Tue Mar 07, 2023 5:58 am

Re: How to only give access if logged into Wordpress?

Post by jongore »

One way to achieve this is to use Single Sign-On (SSO) between your Wordpress site and phpBB forum. With SSO, users who log in to your Wordpress site will automatically be logged in to your phpBB forum without the need to enter their credentials again.

There are several SSO plugins available for phpBB that integrate with Wordpress, such as WP-United and wp2phpBB. These plugins provide a bridge between Wordpress and phpBB, allowing for seamless SSO.

Another approach is to use an authentication plugin for phpBB that supports external authentication sources. For example, the External Login Auth plugin allows users to log in to phpBB using an external authentication source, such as your Wordpress site. This plugin can be configured to use the same authentication cookie as Wordpress, so users who are logged in to Wordpress will be automatically logged in to phpBB.

If you don't want to use SSO or an authentication plugin, you can still restrict access to your phpBB forum based on user roles. You can create a new user group in phpBB and set permissions so that only members of that group can access the forum. Then, you can write a custom script that checks if a user is logged in to your Wordpress site and if they are, adds them to the phpBB user group. This script can be run periodically using a cron job to ensure that user permissions are updated in real-time.

I hope this helps!
User avatar
halil16
Registered User
Posts: 1280
Joined: Fri Jul 24, 2020 11:30 pm
Location: Turkiye
Name: Halil
Contact:

Re: How to only give access if logged into Wordpress?

Post by halil16 »

First: You have to install and run the WP w3all phpBB plugin on WordPress. You have to transfer users and edit settings.

Second: Edit permissions in phpBB. Do not allow access by users who are not logged in. You can even redirect those who are not logged in with a redirect code to the WordPress login page. It would be healthier to use the <!-- IF not S_REGISTERED_USER --> tag for this.

Here a code:

Code: Select all

<!-- IF not S_REGISTERED_USER -->
<meta http-equiv="refresh" content="0;url=/wp-login.php">
<!-- ENDIF -->
add to inline <head>
* Hire me at fiverr for your phpBB board.
"The day we will need ideas more than possessions, we will find the secret to true wealth." - Peyami Safa
I'm learning English...
Contributions: #Hashtag, Elegance, Latte
Post Reply

Return to “phpBB Custom Coding”