Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

J!1.6: Display a different module for each user group

Re: J!1.6: Display a different module for each user group

Ok, so this proves that JomGenius is now returning the correct group names with the info() method. This means that the check() method should be working too.

Can you cut-n-paste the rest of the PHP rule into a forum reply so I can see what you're using? Perhaps there's a simple error there.

Thanks,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: J!1.6: Display a different module for each user group

Here it is:

Code:

echo "Groups: ";

print_r($core_genius->info("groups"));
if ( MM_NOT_LOGGED_IN ) return 43;
if ($core_genius->check("groups = Registrert")) return 110;
if ($core_genius->check("groups = Medlem")) return 112;
if ($core_genius->check("groups = Styret")) return 133;
if ($core_genius->check("groups = Ansatt")) return 5;
if ($core_genius->check("groups = Partner")) return 6;
if ($core_genius->check("groups = Sponsor")) return 7;

I'm guessing the "return 43" part is the problem. It worked until the upgrade, though. smile

General Secretary at Norsk Gründerforum (Norwegian Entrepreneur Forum), an entrepreneurial association with focus on innovation.
http://www.norskgrunderforum.no/
http://www.facebook.com/norskgrunderforum

Midnightman
Beginner Modder
ranks
useravatar
Offline
9 Posts
User info in posts
Administrator has disabled public posting

Re: J!1.6: Display a different module for each user group

Ok, I just changed the:

Code:

if ( MM_NOT_LOGGED_IN ) return 43;

to:

Code:

if ($core_genius->check("groups = Offentlig")) return 43;

(group name "Offentlig" means "Public")

Result:
When not logged in, the "Groups: Array ( )" remains, but module 43 no longer displays. When logged in, I get the same code as before (no module displays).

General Secretary at Norsk Gründerforum (Norwegian Entrepreneur Forum), an entrepreneurial association with focus on innovation.
http://www.norskgrunderforum.no/
http://www.facebook.com/norskgrunderforum

Midnightman
Beginner Modder
ranks
useravatar
Offline
9 Posts
User info in posts
Administrator has disabled public posting

Re: J!1.6: Display a different module for each user group

Hi,

if you're still getting these results:

Groups: Array ( [0] => Member [1] => Superadmin [2] => Board Member [3] => Employee )

... then I don't think that searching for "Public" is going to work. For non-logged-in users, I think that the groups thing should come up with nothing.

Another alternative for the not-logged-in line would be this:

if ($user->id == 0) return 43;

Also, can you please install the latest version of MetaMod - I released v3.9 this week and it may also affect the group information.

Lastly, can you confirm that you definitely have groups with the names that you are checking for above? If you leave the debugging code in place (so it outputs the group names), then log in as a user in one of the groups, then does that exact group name get displayed?

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: J!1.6: Display a different module for each user group

First, let me apologize: The module has been placed in the header section, where its space is restricted. I just tried moving it to the left position, and now I see that MetaMod DOES display the correct module/image.

The problem is the code that displays before the module. It takes up all the space the module has in the header, so that the image doesn't display.

So if I can prevent the code from being displayed, everything will be fine. smile

(Yes, debug is set to "off" in the module params)

I just updated Joomla to 2.5.3 and MetaMod to 3.9. I changed the code according to your suggestions, so this is the code I have now:

Code:

echo "Groups: ";

print_r($core_genius->info("groups"));
if ($user->id == 0) return 43;
if ($core_genius->check("groups = Registrert")) return 110;
if ($core_genius->check("groups = Medlem")) return 112;
if ($core_genius->check("groups = Styret")) return 133;
if ($core_genius->check("groups = Ansatt")) return 5;
if ($core_genius->check("groups = Partner")) return 6;
if ($core_genius->check("groups = Sponsor")) return 7;

When not logged in, this code is displayed before the (correct) image/module:

Code:

Groups: Array ( )

When logged in as "Registrert" ("Registered"), this code is displayed before the (correct) image/module:

Code:

Groups: Array ( [0] => Registrert )

When I log in with my own account (I belong to 4 user groups), this code is displayed before the image/module:

Code:

Groups: Array ( [0] => Medlem [1] => Superadmin [2] => Styret [3] => Ansatt )

FYI: Even though I belong to 4 groups, only one module displays. Not sure if this is right or wrong. It's not a problem to me, just wanted to let you know.

To sum up: I just need to get rid of the code that displays before the module.

Thanks a lot for helping, I really appreciate your great support. smile

General Secretary at Norsk Gründerforum (Norwegian Entrepreneur Forum), an entrepreneurial association with focus on innovation.
http://www.norskgrunderforum.no/
http://www.facebook.com/norskgrunderforum

Midnightman
Beginner Modder
ranks
useravatar
Offline
9 Posts
User info in posts
Administrator has disabled public posting

Re: J!1.6: Display a different module for each user group

Hi,

just remove these lines:


echo "Groups: ";
print_r($core_genius->info("groups"));


About the fact that only 1 module is presented at a time: that's just the way the PHP has been structured above. If you would like a module to appear for each group, not just for the 1st group found, then I can show you a variant of the technique above which does that.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: J!1.6: Display a different module for each user group

Hi all,

I found this post because I need MetaMod to do the same thing; Display certain modules to certain user-groups.

After isntalling the latest Verison of MetaMod: MetaMod 3.9 for 2.5 the code that Stephen provided above worked for me:

if ($core_genius->check("groups = Public")) return 1;
if ($core_genius->check("groups = Registered")) return 2;
if ($core_genius->check("groups = Member")) return 3;
if ($core_genius->check("groups = Board Member")) return 4;
if ($core_genius->check("groups = Employee")) return 5;
if ($core_genius->check("groups = Partner")) return 6;
if ($core_genius->check("groups = Sponsor")) return 7;

This is particularly great because one metamod "mops up" all my user-group specific modules. My site has 18 user-groups with a different header/welcome message for each group, MetaMod makes this EASY!!! smile

I;'m more than happy, thank you for your great work Stephen!

Ray.

igolfniray
Beginner Modder
ranks
useravatar
Offline
16 Posts
Administrator has disabled public posting

Re: J!1.6: Display a different module for each user group

Oh, that's great news Ray, thanks for passing on your code and explaining how it has helped your situation.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1696
Total Polls:
6
Total Posts:
5941
Posts this week:
7
User Info:
 
Total Users:
5408
Newest User:
obtoc67505
Members Online:
1
Guests Online:
3544

Online: 
obtoc67505

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked