-
Hide content from registered users in PHPBB3
Posted on August 17th, 2009 No comments
You might have been in forums where they show ads to guests but not to registered users. Ever wondered how do they do that? Of course there are specific hacks and plugins which do exactly this, but perhaps you’re looking for the most simple and unobtrusive solution. This is exactly what the code in this post offers: it is extremely simple to implement, yet not every PHPBB3 admin knows it.Only the template files need to be modified, so forget about playing around with the core stuff! However, template is a vital part of your forum too, so remember making backups before doing any modifications (just in case…).
Open your template folder and then, the appropriate file for the part of the template you want to modify (header, footer, login screen, posting screen, etc). As an example, we will add a banner to the page header, so every user sees it in every page of the forum, until he logs in.
1. Procedure
1. Firstly backup and then open styles/yourtemplatename/template/overallheader.html
2. At the very end of the file, add the following code. Use it as a sample directly as provided below, or change the banner image and link:
<!-- IF not S_USER_LOGGED_IN --> <div style='text-align:center'><a href='http://www.aleixcortadellas.com' target='_blank'> <img src='http://img205.imageshack.us/img205/5889/testfdk.jpg' width="500" height="90"> </a></div> <!-- ENDIF -->
3. Save and close the template file.
4. Log in to the backend of your PHPBB3 forum. Click the styles tab. On the left menu, select templates.
5. Find the template you’ve just modified in the list of installed templates and in the actions column, click refresh.
Load the forum main screen and you should see the new banner only when not logged in. Congratulations!
2. Additional notes
- If your changes do not show up, make sure you’ve taken steps 4 and 5. The forum is using a cached version of the template, and will not reflect any changes until the cached version is forced to refresh.
- It is possible to achieve the inverse effect – namely, to restrict visibility of the element to registered users only – by using IF S_USER_LOGGED_IN instead of IF not S_USER_LOGGED_IN.
- If you allow users to use multiple templates, remember to take all the steps for each of the available templates separately. This includes refreshing the cached versions as seen in steps 4 and 5!
Computers & programming, PHPBB cms, community, forum, guests, hide, PHPBB, phpbb3, registered, template, usersLeave a reply


