Hack: Hide any module for logged in users ONLY

Your code modifications and patches you want to share with others.
Catzwolf
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Sat Apr 21, 2007 10:47 pm

Re: Hack: Hide any module for logged in users ONLY

Postby Catzwolf » Thu Jul 05, 2007 5:50 pm

No need to use the

Code: Select all

if (!($my->id))
{    echo "<a href='<?php sefRelToAbs("index.php?option=com_comprofiler&task=registers"); ?>' class='help'>Become a member for FREE! </a>"; }

[/quote]

to

Code: Select all

if (!($my->id))
{    echo "<a href='".sefRelToAbs("index.php?option=com_comprofiler&task=registers")."' class='help'>Become a member for FREE! </a>"; }


I know, small little issue :)

ATB

Catz

mgclimber
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jul 11, 2007 8:54 pm

Re: Hack: Hide any module for logged in users ONLY

Postby mgclimber » Thu Jul 12, 2007 4:28 pm

This extended Hack is fantastic, great job!

Totally satisfies my need for more permission flexibility. Hope it makes the core program sometime

Keep em coming


Mike
Last edited by mgclimber on Thu Jul 12, 2007 5:36 pm, edited 1 time in total.

Lottario
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 207
Joined: Wed Jul 04, 2007 2:42 pm

Re: Hack: Hide any module for logged in users ONLY

Postby Lottario » Thu Jul 12, 2007 7:25 pm

Is there a way to make this hack work for Joomla! 1.5, as there is no frontend.php file?

User avatar
phlux0r
Joomla! Guru
Joomla! Guru
Posts: 812
Joined: Thu Feb 09, 2006 1:41 am
Location: Auckland, NZ
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby phlux0r » Fri Jul 13, 2007 3:32 am

Lottario wrote:Is there a way to make this hack work for Joomla! 1.5, as there is no frontend.php file?


Possibly... looking at the /libraries/joomla/application/module/helper.php file, in class JModuleHelper there is the _load() method.

I haven't time to play around with this at the moment but this could be a good starting point...

Lottario
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 207
Joined: Wed Jul 04, 2007 2:42 pm

Re: Hack: Hide any module for logged in users ONLY

Postby Lottario » Fri Jul 13, 2007 6:20 pm

phlux0r wrote:Possibly... looking at the /libraries/joomla/application/module/helper.php file, in class JModuleHelper there is the _load() method.

I haven't time to play around with this at the moment but this could be a good starting point...


Well, I took a look at it, and all I've been able to determine is that I'm nowhere near as good at this as you.  Putting things in if statements that are always true (so that the if statement should have no effect) causes blank pages, but commenting out the same section of code allows the site to load fine....

Anyways, if/when you do get a chance to play with it and get it to work, could you PM me and let me know?

Thanks,
Lott

nityareddy
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Tue Jul 10, 2007 8:29 am

Re: Hack: Hide any module for logged in users ONLY

Postby nityareddy » Tue Jul 31, 2007 11:50 am

thanx
Last edited by nityareddy on Tue Jul 31, 2007 12:38 pm, edited 1 time in total.

aesthitic
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Mon Jul 02, 2007 2:02 am

Re: Hack: Hide any module for logged in users ONLY

Postby aesthitic » Wed Aug 01, 2007 10:07 pm

awesome!

sessus
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Aug 12, 2007 10:10 am

Re: Hack: Hide any module for logged in users ONLY

Postby sessus » Sun Aug 12, 2007 10:14 am

Thank you.

It is a mystery why this is not implemented in the core code.

saetveit
Joomla! Guru
Joomla! Guru
Posts: 536
Joined: Wed Jul 12, 2006 8:11 pm
Location: Ames, IA
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby saetveit » Thu Aug 23, 2007 5:38 pm

This is great!  Has anyone put it on the wishlist?  (1.0.x or 1.5).
Tanzania Partners - A nonprofit group working with Tanzanians for progress.
Shop online and automatically make a donation! - http://www.tzpartners.org
St. Andrew's Lutheran Church, Ames, Iowa, ELCA - http://www.standrewsames.org

lilesjd
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed May 09, 2007 6:16 pm

Re: Hack: Hide any module for logged in users ONLY

Postby lilesjd » Wed Aug 29, 2007 10:00 pm

I have tried it out on two modules and cannot get it to work.  Does it work with 1.013?  Thats the only thing I can think of.  I have followed everything else to the T as far as I know.  I am trying to do it on the cb login and the polls.

Thanks

Jay

saetveit
Joomla! Guru
Joomla! Guru
Posts: 536
Joined: Wed Jul 12, 2006 8:11 pm
Location: Ames, IA
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby saetveit » Wed Aug 29, 2007 10:22 pm

Yes, it works with 1.0.13 for the two modules I've tried it with.  (a mainmenu and a Yanc Newsletter signup module).
Tanzania Partners - A nonprofit group working with Tanzanians for progress.
Shop online and automatically make a donation! - http://www.tzpartners.org
St. Andrew's Lutheran Church, Ames, Iowa, ELCA - http://www.standrewsames.org

lilesjd
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed May 09, 2007 6:16 pm

Re: Hack: Hide any module for logged in users ONLY

Postby lilesjd » Thu Aug 30, 2007 4:04 pm

well then what am I doing wrong...lol! how do i figure that out?

saetveit
Joomla! Guru
Joomla! Guru
Posts: 536
Joined: Wed Jul 12, 2006 8:11 pm
Location: Ames, IA
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby saetveit » Thu Aug 30, 2007 4:22 pm

Did you check in the module settings to see if you've set "Show menu when logged in" to "No"? 

If this option is showing up and you've set it correctly to "No," then it looks like your modification to includes/frontend.php is not correct.

If this option doesn't show up in the module settings, then you have a problem with modification to the module.xml file.

Also make sure you're using the correct hack, as there are more than one given in this thread.

Good luck.
Tanzania Partners - A nonprofit group working with Tanzanians for progress.
Shop online and automatically make a donation! - http://www.tzpartners.org
St. Andrew's Lutheran Church, Ames, Iowa, ELCA - http://www.standrewsames.org

lilesjd
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed May 09, 2007 6:16 pm

Re: Hack: Hide any module for logged in users ONLY

Postby lilesjd » Thu Aug 30, 2007 7:31 pm

I did not check but it WAS set to NO.  But once I opened the module then saved it upon exiting the module it began to work fine.  This is so AWESOME!  Thanks GUYS!

saetveit
Joomla! Guru
Joomla! Guru
Posts: 536
Joined: Wed Jul 12, 2006 8:11 pm
Location: Ames, IA
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby saetveit » Thu Aug 30, 2007 7:35 pm

Great!  I'll have to remember that you have to open and save the module settings when you implement this hack so I don't get tripped up sometime.

I wish this hack were incorporated into the core (if not this hack, then another way to give this functionality)!  It's such a useful feature.
Tanzania Partners - A nonprofit group working with Tanzanians for progress.
Shop online and automatically make a donation! - http://www.tzpartners.org
St. Andrew's Lutheran Church, Ames, Iowa, ELCA - http://www.standrewsames.org

User avatar
trek66
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Wed Aug 22, 2007 1:51 pm
Location: Boston, MA, USA
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby trek66 » Fri Sep 21, 2007 2:04 pm

This is a absolutely brilliant, works like a charm.  thanks!!
High Rock Media Web Development
http://www.highrockmedia.com

amotaz
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Jun 08, 2007 12:24 am

Worked perfectly!

Postby amotaz » Fri Oct 19, 2007 8:52 am

Exactly what I needed! Worked perfectly on J! 1.0.13.

Thanks! :)
Last edited by amotaz on Fri Oct 19, 2007 8:55 am, edited 1 time in total.

ThePiston
Joomla! Guru
Joomla! Guru
Posts: 623
Joined: Mon Nov 07, 2005 3:45 am
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby ThePiston » Wed Oct 31, 2007 8:33 pm

this is awesome - if you need it to work for a custom module, then edit the custom.xml file in modules.

User avatar
joomlamoves
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 111
Joined: Fri Sep 02, 2005 4:29 pm

Re: Hack: Hide any module for logged in users ONLY

Postby joomlamoves » Mon Dec 03, 2007 10:11 pm

Has anyone hacked J1.5 to hide public access menu items when a user logs in?

Will this functionality be included in the eventual ACL updates to 1.5?
dreary query begone

scleaves
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Mon Jul 16, 2007 3:37 am

Re: Hack: Hide any module for logged in users ONLY

Postby scleaves » Sun Dec 30, 2007 3:10 am

Just wanted to add my TREMENDOUS thanks for this AWESOME Hack. Another vote for the wishlist - feature request - whatever etc to make this part of the core!  ;D

scleaves

dkirk
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Fri Dec 08, 2006 1:58 pm
Location: Riverside, California
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby dkirk » Thu Jan 03, 2008 10:07 pm

Thanks to everyone that contributed to this hack. Unfortunately while it works exactly as written, we still get the annoying IE pop-up, "This page contains both secure and nonsecure items."

We only have five 'modules' published, I have unpublished all of them, set all of them to using the hacks, yet the pop-up continues.

Using Joomla 1.0.13 with Virtuemart 1.0.13a.

saetveit
Joomla! Guru
Joomla! Guru
Posts: 536
Joined: Wed Jul 12, 2006 8:11 pm
Location: Ames, IA
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby saetveit » Thu Jan 03, 2008 10:09 pm

darkhelmet wrote:...we still get the annoying IE pop-up, "This page contains both secure and nonsecure items."



Simple solution!  Don't use IE!  :)
Tanzania Partners - A nonprofit group working with Tanzanians for progress.
Shop online and automatically make a donation! - http://www.tzpartners.org
St. Andrew's Lutheran Church, Ames, Iowa, ELCA - http://www.standrewsames.org

dkirk
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Fri Dec 08, 2006 1:58 pm
Location: Riverside, California
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby dkirk » Thu Jan 03, 2008 11:44 pm


Simple solution!  Don't use IE!  :)



That helps us, and I am sure anyone else with a similar issue, very little.

This is a business Web site, internally we use Firefox, and I cannot imagine posting a message on the site that our viewers must not use a specific browser or else. We test all our Web sites across a wide range of browsers to ensure compatibility, and as usual Internet Explorer ranks the highest on the non-compatibility scale.

Your comment however is a 'simple' solution - I was hoping for something far more useful.

saetveit
Joomla! Guru
Joomla! Guru
Posts: 536
Joined: Wed Jul 12, 2006 8:11 pm
Location: Ames, IA
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby saetveit » Fri Jan 04, 2008 3:12 am

it was a joke... come on...
Tanzania Partners - A nonprofit group working with Tanzanians for progress.
Shop online and automatically make a donation! - http://www.tzpartners.org
St. Andrew's Lutheran Church, Ames, Iowa, ELCA - http://www.standrewsames.org

rgoldin
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Jan 07, 2008 8:19 pm

Re: Hack: Hide any module for logged in users ONLY

Postby rgoldin » Tue Jan 22, 2008 9:20 pm

darkhelmet wrote:...the annoying IE pop-up, "This page contains both secure and nonsecure items."


I have used this on 1.0.13 and also say THANKS it works great.

darkhelmet, this is usually caused by http:// and https:// on the same page.  Look in your source code (view source) to see if that is true.  It doesn't sound like it would have anything to do per-say with this hack.

dkirk
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Fri Dec 08, 2006 1:58 pm
Location: Riverside, California
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby dkirk » Tue Jan 22, 2008 11:03 pm

You are correct - we had to hire someone to make some changes to the code in order for the pop-up to go away. Almost everything is working properly now.

miked333
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Feb 02, 2008 3:10 am

Re: Hack: Hide any module for logged in users ONLY

Postby miked333 » Tue Feb 12, 2008 1:44 am

This hack works perfectly!  Thank you for making it.  Is there any way to do the same thing for mambots?

fbaragona
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Feb 15, 2006 5:48 pm

Re: Hack: Hide any module for logged in users ONLY

Postby fbaragona » Fri Feb 15, 2008 4:00 pm

Tested on a custom module for Joomla 1.0.14, works great. If you are using Joomfish, dont forget to go to your language translations and tick the radio button on the module for the translation as well.

I am using this hack with the latest version of DOCMAN, as there have been complaints that docman does not permit admins to allow non-registered users to only view documents, where only registered users can download. This is not entirely true, docman does allow a VIEW ONLY feature, but it does not include a message that informs users they need to register to download, which can be confusing for users. The solution is to use this hack, create a custom module informing users they need to register to download, and once logged in the module disappears. Thanks!

radicalz
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Nov 16, 2007 8:13 am

Re: Hack: Hide any module for logged in users ONLY

Postby radicalz » Sun Mar 02, 2008 3:50 am

phlux0r wrote:To add the possibility of hiding modules for a certain user group (i.e. Authors, Publishers, Managers etc.) this is what is needed:

1) In your /modules/[whatever_module].xml you need to add the following somewhere within the section:

Code: Select all

      <param name="show_registered" type="radio" default="1" label="Show Menu When Logged In" description="Show the menu also when a registered user is logged in">
         <option value="0">No</option>
         <option value="1">Yes</option>
      </param>
      <param name="hide_for_gid" type="list" default="0" label="Hide Module for this User Type Only" description="If above is set to 'No', you can specify which registered user type you want to hide this module for. Default hides the module for any logged in user.">
         <option value="0">Default</option>
         <option value="18">Registered</option>
         <option value="19">Author</option>
         <option value="20">Editor</option>
         <option value="21">Publisher</option>
         <option value="23">Manager</option>
         <option value="24">Administrator</option>
         <option value="25">Super Administrator</option>
         <option value=">19">Author and above</option>
         <option value=">20">Editor and above</option>
         <option value=">21">Publisher and above</option>
         <option value=">23">Manager and above</option>
         <option value=">24">Administrator and above</option>
         <option value="<19">Author and below</option>
         <option value="<20">Editor and below</option>
         <option value="<21">Publisher and below</option>
         <option value="<23">Manager and below</option>
         <option value="<24">Administrator and below</option>
      </param>



Hi guys.. I'm new in this Joomla coding thing. I tried to put it in the .xml file of any module (including Joomla's default module), and I can't get the new parameters out in the module setting. I'm using Joomla v1.0.12.

phlux said, "add the following somewhere within the section". What section is this? I tried to edit installed module, and put it between <params> </params> and it didn't work. I tried editting a module and installed it to Joomla, it said "not Joomla xml format".

Can anyone help me pls? I don't know what to do. ???

User avatar
timdavies
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Feb 19, 2008 6:45 pm
Location: Worthing, UK
Contact:

Re: Hack: Hide any module for logged in users ONLY

Postby timdavies » Tue Apr 08, 2008 2:10 pm

Personally I would just build it into the template. Customise the template not the core code. Use php in the template to decide whether or not to hide the module to logged in users. use code like this for example in the template

Joomla 1.0
if( !$my->id )mosLoadModules ( 'left' );

Joomla 1.5
<?php
$user =& JFactory::getUser();
$user_id = $user->get('id');
if (!$user_id)
{
?>
<jdoc:include type="modules" name="left" />
<?php
}
?>


Return to “Core Hacks and Patches”

Who is online

Users browsing this forum: No registered users and 0 guests