Skip to content

Modules Shown Only to Logged In Users

Modules can be shown only to logged in users of your Mambo web site through the use of PHP in your Mambo templates. Below, I show you how to hide modules from from site visitors and have them displayed to registered users who have logged in. This is achieved by a small snippet of PHP code that tells Mambo when to display the module.

Example:

<?php if ( $my->id ) {
  mosLoadModules('logged_in_position');
} ?> 

- where logged_in_position is whatever position name you choose for the module you wish to show to registered/logged in users.

If you want to display one module for logged in users and a different module to site visitors that are not logged in, use this:

<?php    if ( $my->id ) {
     mosLoadModules('logged_in_position');
} else {
     mosLoadModules('other_position');
} ?> 

- where other position is whatever module position you wish to display to visitors who are not logged on.

This tutorial is part of a series about working with modules. Look for more information about working with modules in our template tutorials.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Topic: Mambo Tutorials
Tagged as: Mambo, modules, templates

Share on FriendFeed

{ 0 comments… be the first to comment }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Any comments that look like spam will be treated as spam - this includes SEO titles and use of spurious keywords.

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.