"Helping businesses operate more effectively online"

14

Apr

2008

How to hide content from registered users and guests in Joomla 1.5
Written by David Towers   

Hide content from guests When building a website with Joomla 1.5, you might need to hide content from registreted users and guests. When we were recently building a website with Joomla 1.5, we came across the 3 options:

In this post we will be discussing the pros and cons of each of these plugins and explaining how to make RokAccess work in Joomla 1.5.

Hiding content depending on whether a user is a registered member or a guest is a really useful feature to have. Fortunately, there are a number of different options available set content permissions in Joomla 1.5...

JoomiHide

How JoomiHide works

This is the simplest plugin available for Joomla 1.5 to hide content. Although it's simple it works seamlessly for showing content either to registered members or guests.

Content in an article can be restricted to be displayed to certain visitors by adding these tags:

{reg} This content is only displayed to registered users logged in {/reg}
{unreg} This content is only displayed to unregistered users or non-logged in users {/unreg}

When content is restricted for non-members, this plugin replaces the restricted text with: "To view rest of this section, please login or register". This is a nice feature but a little annoying to have it displayed each time content is not displayed. To remove or edit this text, you can hack the plugin by changing the html code on line 108 of joomihide.php which is in /plugins/content/.

Unlike content restricted for non-members, when content is not shown to registered users there is no text added.

Pros

  • Simple

Cons

  • Downloading this membership at HowIDid Academy which will set you back $10 for 3 months.
  • Content can only be hidden to members and non-members: There is no option of showing content to administrators or other Joomla groups
  • Need to hack the plugin to remove or change the text displayed when content restricted for guests

Click here to see what other people are saying about JoomiHide. Click here to download this plugin.

Ninja Access

How Ninja Access works

Hide content using this plugin by surrounding the content you want to be seen by certain groups in a tag. Ninja Access uses numbers to specify which group the content includes:

{njaccess 0} Shows this content only to guests {/njaccess}
{njaccess 18,19,20,21,23,24,25}
Shows this content to all users who are guests {/njaccess}
{njaccess 24,25,30,31}
Shows this content to administrators and 2 custom groups created in JACL {/njaccess}

When content is not shown to a particular group, the text is simply hidden.

As you can see from the examples above, you need to know the default Joomla GroupIDs: 0 - Guest, 18 - Registered, 19 - Author, 20 - Editor, 21 - Publisher, 23 - Manager, 24 - Administrator, 25 - Super Administrator.

Pros

  • Very complete plugin for hiding content for specific groups including groups created with JACL
  • Great support from the Ninjoomla team

Cons

  • You need to have the GroupIDs at hand when you use this plugin.
  • Downloading this requires Silver Membership at NinJoomla which will set you back $30.

Find out more about Ninja Access here.

RokAccess

RokAccess is an extremely popular plugin for Joomla 1.0, but hasn't yet been updated for Joomla 1.5. Thanks to Lukas White, we managed to get RokAccess working in Joomla 1.5.

How to get RokAccess working in Joomla 1.5

After installing the Joomla 1.0 RokAccess extension on your Joomla 1.5 website, you will need to change the rokaccess.php file which is located in /plugins/content/

There are 3 changes you need to make to this file:

$_MAMBOTS->registerFunction( 'onPrepareContent', 'botRokAccess' );
Change to:
$mainframe->registerEvent( 'onPrepareContent', 'botRokAccess' );
function botRokAccess( $published, &$row, &$params, $page=0 )
Change to:
function botRokAccess( &$row, &$params, $page=0 ) {
Delete:
if (!$published) {
       $row->text = preg_replace( $regex, '', $row->text );
       return;
   }

How RokAccess works

To hide content using the RokAccess plugin you add the RokAccess tag to the content you want to hide. Here are some examples:

{rokaccess guest} Shows this content only to guest users {/rokaccess}
{rokaccess !guest}
Shows this content to all users who are not a guest {/rokaccess}
{rokaccess registered}
Shows this content to all users who are registered {/rokaccess}
{rokaccess guest,!editor}
Shows this content this to all guests and members who are not editors {/rokaccess}
{rokaccess editor,special}
Shows this content to editors, administrators, and superadministrators {/rokaccess}

In similarity to Ninja Access, when content is not shown to a particular group, the text is simply hidden.

Pros

  • Free
  • Complete

Cons

  • You need to hack the plugin files to get this working in Joomla 1.5
  • No support

Click here to see what other people are saying about RokAccess. Click here to download this plugin.

Which should plugin should you choose?

It just depends on what your needs are. We recommend you choose the plugin you're comfortable using... If you don't want to hack any files and need support with getting the plugin to work, we recommend you use the Ninjoomla plugin.

Do you have any experience with these plugins? We welcome your comments below.

Comments (49)Add Comment
Alex Ashman
Alex Ashman
April 15, 2008
82.36.123.218
Votes: +5
...

You said that RokAccess was for Joomla 1.0 - if I want to use it in Joomla 1.5 like you state do I have to have legacy mode enabled?

Jason Boyette
Jason Boyette
April 16, 2008
199.178.199.254
Votes: +1
...

No, I think you just have to hack the rokaccess.php file as described in the article.

David Towers
David Towers
April 16, 2008
205.167.7.18
Votes: +3
...

You're spot on GreatGatsby, RokAccess should work without legacy mode enabled. Welcome to GoodWebPractices by the way!!!

0
Mark Simpson
April 17, 2008
210.7.24.190
Votes: +1
...

Hi David,

Thank you for featuring Ninja Access in your article. smilies/smiley.gif

$30 is a heck of a lot to pay for Ninja Access (I wouldn't pay that myself unless it was for a well-paying client project), so I just wanted to stress again that the $30 is for membership in the club, which means you actually get dozens of professionally supported extensions for the $30.

Also, Ninja Access... like all the other extensions we provide to our members, is not proprietary and can be used on as many websites as one wishes.

Thanks again for the mention David. If this post sounds more "salesy" then informative, apologies and feel free to delete it.

Cheers

David Towers
David Towers
April 17, 2008
205.167.7.18
Votes: +1
...

Thanks for pointing that out Mark.

The Ninja Access Silver Membership gives access to lots of other extensions, but as I stated in my post the key advantage to the Ninja Access plugin is the professional support. I expect some of our readers will choose to use Ninja Access because of the support rather than the actual extension being better than the others.

0
aravot
April 19, 2008
24.205.51.108
Votes: +3
...

For php5 change this
function botRokAccess( &$row, &$params, $page=0 ) {
to this
function botRokAccess( $row, $params, $page=0 ) {

0
Salyris Studios
April 19, 2008
24.21.216.142
Votes: +2
...

Great article David!

I am curious if you have tried out or looked at JoomSuite J!1.5 extensions: http://joomsuite.com/

Let me know your thoughts.

David Towers
David Towers
April 22, 2008
205.167.7.18
Votes: +0
...

Thanks Aravot for that.

Salyris Studios, I haven't actually used any of your extensions yet.

Am I right in thinking your "JoomSuite Permission" extension would allow the restricting of content based upon membership? Perhaps you could tell us more about it?

David Towers
David Towers
May 02, 2008
87.90.44.16
Votes: +0
...

There is a new plugin from GreatJoomla.com which also control display of content to just the site users that you want to have see it, here is the link: http://extensions.joomla.org/c...Itemid,35/

0
Salyris Studios
May 03, 2008
24.21.216.142
Votes: +1
...

Sorry David, the JoomSuite are not a Salyris Studios product, I was just curious if you knew much about them or used them. ;-)

David Towers
David Towers
May 04, 2008
87.90.44.16
Votes: +1
...

Ok my mistake! smilies/smiley.gif Well I haven't tried the JoomSuite extensions yet...

0
Kevin
May 23, 2008
117.19.21.101
Votes: +1
...

Thanks for the info here. I thought I'd add some info on JoomSuite products as I've purchased four of them; JoomMember, JoomUser, JoomContent, and JoomDefender. While I think these components have potential, they are all technically still in beta. Support is just ok, so expect to wait a few days for responses. The English in all the components is atrocious, so plan on digging through the ini files. Note that all components are also encrypted, so customization is limited. This being said, JoomUser is pretty stable but does require a hack to your login mod if you don't use theirs, but I held off on buying the permissions component due to way too many bugs. I'd say visit them in August when they claim their components will be officially released.

David Towers
David Towers
May 23, 2008
205.167.7.18
Votes: +0
...

Thanks for the feedback re: JoomSuite's products Kevin! smilies/smiley.gif

0
hyunkeln
June 19, 2008
201.110.43.180
Votes: +0
...

Does RokAccess work with 'JXtended Control' defined user groups?

Thanks!

0
Andrea
July 08, 2008
71.209.68.10
Votes: +0
...

re: Rok Access ...

Easy, and exactly what I needed! I'm redesigning the website for the church I work at, and we need/want to keep some areas accessible to registered users (church members) only. I'm working on a photo gallery, and instead of having 2 galleries, this lets me work around and only have one, showing the restricted galleries to members.

I did have to enable legacy mode to install the plugin. After that, I just had to make those 3 changes, and Bob's your uncle!

I had to leave legacy mode enabled to avoid this error message ...

"Direct Access to this location is not allowed."

... Not a big deal, and with my luck, it won't happen to others, but a heads-up nonetheless.

David Towers
David Towers
July 08, 2008
87.90.44.16
Votes: +0
...

Great thanks for the info Andrea! Glad you found it useful. Feel free to post the address of the site you've been using it on! Cheers.

0
Marco
July 22, 2008
213.190.192.221
Votes: +0
...

Even with the changes you indicated to make it work with Joomla! 1.5, I still had a problem that appeared on all my site's pages:
Direct Access to this location is not allowed.

So, I made this change:
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
to:
defined( '_JEXEC' ) or die( 'Restricted access' );

Hope it helps. Thanks for tips. smilies/wink.gif

0
Marco
July 22, 2008
213.190.192.221
Votes: +0
...

Hmmmm.... After posting my comment I've noted that Andrea had the same problem about Direct Access. I think the best way to solve this is to change the code as I mentioned before instead of turning legacy mode on smilies/grin.gif.

Cheers.

0
Sandra
August 06, 2008
190.50.45.195
Votes: +0
...

Thanks!!!

I have been using rokaccess in most my 1.0.x sites and now I was missing it for 1.5. This is great!!!!!!! smilies/cool.gif smilies/cheesy.gif

0
Dana
September 04, 2008
75.150.45.129
Votes: +0
...

Rokaccess is an ESSENTIAL part of my Joomla 1.0.x site and now I'm upgrading to Joomla 1.5. I've tried the hack mentioned above and it seems to work for my content items, but NOT in the modules I also use Rokaccess in. Can anybody confirm that this hack does not work within modules or did I do something wrong? Also, thanks for the informative article.

Jason Boyette
Jason Boyette
September 24, 2008
199.178.199.254
Votes: +1
...

I like what Andrea had to say; I also have a church site with similar requirements. However, I'm wondering if there's a way to make certain groups of users have access to certain content.

For instance, I would like our staff to have access to internal church documents, but not all registered users. And I don't want to make all the staff Authors, Editors or Publishers. I would like a custom group like "Staff". I'd like multiple groups, each with their own access control, and the ability to show/hide content to one or more of the groups.

0
Kevin
September 26, 2008
59.115.176.183
Votes: -2
...

I wanted to chime in again to let folks know that the Joomsuite extensions I reviewed earlier this year have been updated. I'm very happy with JoomMember and JoomUser, but there are some hacks that may be needed to get things working with thrid-party login modules and member registration.

I thought it would be worth mentioning a post in the Joomla forum with instructions on how to hack the Joomla core to hide complete modules when users are logged in (http://forum.joomla.org/viewtopic.php?f=178&t=114630&p=1379447&hilit=hide+module+registered#p1379447). I've performed these hacks on Joomla 1.5.6 and 1.5.7 with great success. The benefit to this is that any module can be hidden to registered users, not just a mod_custom. So you can hide Yootheme and NinjaForge extensions with some simple cut and paste. Of course, you have to redo the hacks every time you upgrade, but there are only two core files to change. The benefits far outweigh the inconvenience. Hope this helps some of you.

0
Mark Simpson
September 29, 2008
210.7.9.168
Votes: +0
...

Hi guys smilies/smiley.gif
I just wanted to let your readers know that NinjaForge silver memberships are now only $5. (Was $30 when this review was written)

Hope this post is acceptable. Feel free to remove if not.

Thanks

0
Alvin
October 24, 2008
124.178.253.78
Votes: +3
...

I'd like to recommend a plugin called 'Hider'.
It's pretty basic, but does the job really well.

{reg}Only registered users will see this text{/reg}
{pub}Only non-registered users will see this text{/pub}

http://www.dioscouri.com/freedownloads/Download/HIDER-HideContent/

0
Jim
November 04, 2008
72.49.158.250
Votes: +0
...

I installed Hider and it worked well within the articles, but when I tried to implement it within a custom template, {reg}Organization:{/reg} actually was outputted on the page in the browser as "{reg}Organization:{/reg}". Any ideas on how to get this to work within the template html?

0
massimo
November 28, 2008
77.242.208.51
Votes: +0
...

hi guys

i am migrating to j1.5 and i used rokaccess. and i was satisfied.

now in j1.5 what can i use?

i need to hide content in the modules.

hider of dioscuri not works in the module.

give a look club.hotelsinitaly.travel

the other plugins?

David Towers
David Towers
November 29, 2008
94.192.221.190
Votes: +0
...

Hi massimo. In Joomla 1.5 we've tried a few different options, you can actually get RokAccess working in Joomla 1.5 if you use the hack mentioned in the blog post above. For hiding content in modules, you could just make it so the module is only visible to registered users, would that work?

0
massimo
December 01, 2008
77.242.208.51
Votes: +0
...

hi david,

rokaccess it doesn't work neither with hack also.

i need to make some txt available only to registered and another part only to guest.

I have tried some components but nothing works on my site. i don't why.

0
David T
December 01, 2008
193.23.120.250
Votes: +0
...

Hi again, that is strange. Have you tried Hider? http://www.dioscouri.com/freed...deContent/ ?

Otherwise, could it be an issue with your editor perhaps?

0
massimo
December 01, 2008
77.242.208.51
Votes: +0
...

i need to hide content inside the modules rokaccess worked in that way, in j1.5 no.

hider can hide content in the module?

thanks for your help.

0
Disco Stu
December 16, 2008
212.135.88.100
Votes: +0
...

I have succesfully installed RokAccess on 1.5, a huge thanks guys, but I can confirm it does not work in my modules.

Here's my dilema, the content in a module is differnet for a registerd user than a guest, but I can't hide the guest module from a registered user, or can I?

Help apreciated

0
Denton
February 11, 2009
60.241.203.191
Votes: +0
...

Great article David on getting RokAccess for 1.5.

I've followed the above instructions as well as those by baravot and Marco, but still am not able to get it working.

Works when I turn Legacy mode on though. Can anyone confirm they've got it working on 1.5 and maybe paste up their php code?

Thanks

0
rocky
February 26, 2009
84.245.18.225
Votes: +1
...

Is there a way to hide a menu item (register here) from a main menu when you are registered? Or change it to something else (my menu)?

0
mark
March 20, 2009
87.7.90.2
Votes: +0
...

doesn't work in modules content smilies/sad.gif

0
chrisp
June 09, 2009
213.61.58.66
Votes: +0
...

Hi.
I have install rocaccess and do the changes to work with J!1.5

But now, when i save the article with the variables for example {rocaccess guest}123{/rokaccess}

then comes an error like this:

Parse error: syntax error, unexpected $end in /......./plugins/content/rokaccess.php on line 107

0
Artur
July 07, 2009
83.19.143.100
Votes: +0
...

Because of REGISTER_GLOBALS set to OFF in PHP 5 i suggest to change:
global $my;
to:
$my =& JFactory::getUser();
in function botRokAccess_replacer.
Best regards.

0
farid
August 06, 2009
60.51.27.26
Votes: +0
...

I just wondering whether is there any joomla plugin or anything that can show hidden content after user post a reply in that posting.

This method was used in lot of forum...'reply to show hidden content'


0
julien
August 30, 2009
41.227.234.192
Votes: +0
...

i'm using ninja access and when i restrict content i get an error message:

Parse error: syntax error, unexpected T_STRING in /home4/../plugins/content/njaccess.php(72) : eval()'d code on line 1

can you help me to resolve this problem!!
thank you!

sofiene
sofiene
August 31, 2009
41.227.234.192
Votes: +1
...

i'm using ninga access but i get this error:
Parse error: syntax error, unexpected T_STRING in /home4/.../plugins/content/njaccess.php(72) : eval()'d code on line 1

can you help me?
thank you!

0
Chuck Williams
December 30, 2009
98.191.19.196
Votes: +0
...

Hi,

I just tested the RokAccess plug-in in Joomla 1.5 and it works fine...but is only removes the content and it is blank...how to add something like.."To view this page, please register".

Thanks for any help

0
Bo Astrup
December 30, 2009
75.50.160.201
Votes: +0
...

to hide modules for certain groups of users - and much more - advanced Module Management from nonumber.nl is the best.

0
Arizona Vacation Rentals
March 04, 2010
112.202.15.224
Votes: +0
...

Why hide when you want to get benefits from search engine to index the newly added contents?

0
Melroy
March 20, 2010
212.238.159.185
Votes: +0
...

Just download:

http://www.dioscouri.com/index.php?option=com_ambrasubs&view=categories&categoryid=9&Itemid=43

Its free also...

0
christian
September 23, 2010
99.140.78.73
Votes: +0
...

The Dioscouri is the best option...

0
Darrel
October 05, 2010
86.219.189.91
Votes: +0
...

Yes, the Hider plug-in works fine with no problems.

I couldn't get the Rok plug-in to work at all and the Ninja thing seems expensive for what I need.

0
redesigner
February 07, 2011
217.35.34.180
Votes: +0
...

Just thought I'd put my 2p in.
I tried RokAccess but to no success on 1.5 but I did find one that does work straight out the box with no editing of code required. Its called Joomla Article Access and listed here: http://bit.ly/dTxKzm
or search Joomla extensions for Article Access

0
mens Chloe sunglasses
May 17, 2011
76.73.26.109
Votes: +0
...

This article is really very infectious, impress everyone's heart. Thank you for the article-mens Chloe sunglasses

0
MarkupBox
June 07, 2011
110.234.16.100
Votes: +0
...

MarkupBox.com is one of the most reputed PSD to HTML/CSS service providers. We have the profound experience in converting every kind of PSD design to suitable and user friendly HTML/CSS markup. We are dedicated to provide high quality PSD To HTML/CSS & theming services, Table-less HTML with SEO semantic code and optimized shorthand CSS.

0
justinspenser
June 07, 2011
110.234.16.100
Votes: +0
...

We offer a wide range of conversions like- PSD to WordPress, PSD to Drupal, PSD to Joomla, PSD to Magento etc. We understand the importance of conversion in the process of web designing & development. This is why we have a highly qualified team of web designers and developer who understand the complexities involved in this conversion and provide the best results to our clients. We offer flexible packages. We have a large client base from different countries.

Write comment
 
  smaller | bigger
 

busy