Custom User Group DONE, but Menu Item NOT APPEARING

Your code modifications and patches you want to share with others.
jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Mon Nov 09, 2009 2:28 am

Hi guys,

I have create an additional user group called 'Registered Dealers' with same access levels as the Joomla current 'Registered' group
by following the tutorial here > http://docs.joomla.org/Custom_user_groups

Unfortunately, when I set my menu item Access Level to this group (Registered Dealers), it's not showing...

But if I change the Access Level to 'Registered' group, then it display well...

Any idea how to solve this problem ?

Thanks in advance.

schlogo
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Sat Nov 19, 2005 4:35 pm
Location: France
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by schlogo » Mon Nov 09, 2009 12:00 pm

I am interested in that as well. I ve crowled the forum and applied some solutions I ve found, nothing works

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Mon Nov 09, 2009 1:49 pm

It's strange why this won't work... perhaps someone can share some ideas here..

I found this reading.. http://www.guylabbe.ca/en/blog/custom-c ... roups.html
I dono whether this will contribute some understanding to the problem I am having now..

Can anyone share some ideas ?

Thanks.

schlogo
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Sat Nov 19, 2005 4:35 pm
Location: France
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by schlogo » Tue Nov 10, 2009 9:03 am

hello

it does not add much to what s in the joomla documentation ... if someone would help on that, it would be very nice

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Fri Nov 13, 2009 3:50 am

Really appreciate anyone could share your solution here.

Thanks & thanks again.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Tue Nov 24, 2009 4:02 pm

Maybe you can give more details.
Starting with: which Joomla version do you have?

What did you try so far, what did not work.

Where you able to assign the group to the user?
Was that information saved in the database?
etc.

Mod Note: Bump post deleted, please do not bump your posts.

Olaf
Olaf Offick - Global Moderator
learnskills.org

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Wed Nov 25, 2009 1:44 am

ooffick wrote:Maybe you can give more details.
Starting with: which Joomla version do you have?

What did you try so far, what did not work.

Where you able to assign the group to the user?
Was that information saved in the database?
etc.

Mod Note: Bump post deleted, please do not bump your posts.

Olaf
Hi Olaf,
Thanks for responding to my thread :)

I created an additional user group called 'Registered Dealers' with same access levels as the Joomla current 'Registered' group
by following the tutorial here > http://docs.joomla.org/Custom_user_groups

Well, My Joomla version is v1.5.10.
Yes I am able to assign group to the user. (Note : I noticed at the backend, the original 'Registered' group is in red color, but the group 'Registered Dealers' that I created is in black color. Anything wrong ?)

I also checked through my database, yes it's successfully recorded in.

Any idea ? Thanks.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Wed Nov 25, 2009 8:51 am

Did you run the script to rebuild the groups tree as well?

Olaf
Olaf Offick - Global Moderator
learnskills.org

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Wed Nov 25, 2009 6:06 pm

ooffick wrote:Did you run the script to rebuild the groups tree as well?

Olaf

Hi Olaf,

Yes I did..

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Wed Nov 25, 2009 8:30 pm

ok, let me see:

In the Menu Manager/Article Manager/Module Manager you can only select between the access level Public, Registered and Special

What is the parent element of your new group?
Which access level did you select?

Olaf
Olaf Offick - Global Moderator
learnskills.org

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Thu Nov 26, 2009 1:39 am

ooffick wrote:ok, let me see:

In the Menu Manager/Article Manager/Module Manager you can only select between the access level Public, Registered and Special

What is the parent element of your new group?
Which access level did you select?

Olaf

Hi Olaf,

In the Menu Manager/Article Manager/Module Manager , I can select Public, Registered, Special and as well as the new group "Registered Dealers" too.

The group "Registered Dealers" has the exactly the same parent & access level as the "Registered" group.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Thu Nov 26, 2009 9:49 am

And what did you change to let the new group appear in the Access Level Drop Down field.

Olaf
Olaf Offick - Global Moderator
learnskills.org

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Thu Nov 26, 2009 3:08 pm

ooffick wrote:And what did you change to let the new group appear in the Access Level Drop Down field.

Olaf

Hi Olaf,

I follow the instructions at http://docs.joomla.org/Custom_user_groups

At the bottom of this page, it says the following :

When you want to use the custom groups to assign to your articles so that for example only the customers can view specific articles you need to add these groups into the jos_groups, just assign the ID + name of the group whereby the name must be equal to the groups names you added into the jos_core_acl_aro_groups table.

So I follow this, & I got the group "Registered Dealers" appear at the drop down for selection.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Fri Nov 27, 2009 11:53 pm

Hi,

I don't think it is that easy to change that, I say you will need some other change as well.

You might want to look at the code of Joomla 1.6 and make it work in Joomla 1.5 or use one of the existing extension.

Olaf
Olaf Offick - Global Moderator
learnskills.org

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Sat Nov 28, 2009 4:30 am

ooffick wrote:Hi,

I don't think it is that easy to change that, I say you will need some other change as well.

You might want to look at the code of Joomla 1.6 and make it work in Joomla 1.5 or use one of the existing extension.

Olaf

Hi Olaf,

I guess I must have some part perhaps I have left out... But I already made sure I follow exactly whatever it is highlighted in the tutorial.

I see the Joomla "Registered" group is in "RED" color, but the Registrered Dealers" group I created is in "BLACK" color... perhaps anyone can help to think from this point ?

Thanks.

Neelay
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Sat Nov 24, 2007 2:43 pm

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by Neelay » Sat Nov 28, 2009 9:20 am

Me too require a working solution. Olaf, I checked the Joomla 1.6, seems that it handles usergroups by just two tables - _users and _user_usergroup_map. Will be difficult to explore it just to get this solution. Appreciate your help.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Sat Nov 28, 2009 6:53 pm

The problem is that the user's aid is still set to 1 even though the user is in the new group.

Moreover, the authorization fails, as the user requires to have an access level higher or equal to 3 (if that's the ID of the new group in the jos_groups table)

So I don't think you will be able to hack the core files that easy to create a new group.

Olaf
Olaf Offick - Global Moderator
learnskills.org

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Sun Nov 29, 2009 9:25 am

ooffick wrote:The problem is that the user's aid is still set to 1 even though the user is in the new group.

Moreover, the authorization fails, as the user requires to have an access level higher or equal to 3 (if that's the ID of the new group in the jos_groups table)

So I don't think you will be able to hack the core files that easy to create a new group.

Olaf
Hi olaf,

Thanks once again for following up with this topic.

I'm sorry, I'm not getting what you meant by "The problem is that the user's aid is still set to 1 even though the user is in the new group.

Moreover, the authorization fails, as the user requires to have an access level higher or equal to 3 (if that's the ID of the new group in the jos_groups table)."


Is is really possible to have a get around this ?

Thanks Olaf & perhaps others could contribute some solutions to this problem as well.

Iain_H
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Dec 13, 2009 3:34 pm

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by Iain_H » Sun Dec 13, 2009 4:12 pm

This is my question as well - how to get stuff accessible on a user basis...

Joomla 1.5.15

I am doing a website for a swimming club and I would like :-
  • Registered: new people who are interested
    Members: people who have joined
    Coaches: Staff
    Committee: Staff
I altered the administrator/components/com_users/admin.users.php file line 113

Code: Select all

$gtree = $acl->get_group_children_tree( null, 'USERS', true );
I added the new groups to jos_core_acl_aro_groups so that they sit like this:-

Front-End-Users
  • Registered Users
    • Author
      • Editor
        • Publisher
      Member
      • Coach
        Committee

Code: Select all

Member is ID 31, parent 19 (Registered)
Coach is ID 32, parent 31 (Member)
Committee is ID 33, parent 31 (Member)
I ran the rebuild script with paramters (0,1) and (0,0) - neither seem to make a difference to how Joomla operated afterwards

The user editor now shows the new groups in the way I would expect.

I added the new groups into jos_groups

Code: Select all

31, Member
32, Coach
33, Committee
This allows the menu editor to show the new groups

I added the following lines to \administrator\components\com_users\config.xml

Code: Select all

<option value="Member">Member</option>
<option value="Coach">Coach</option>
<option value="Committee">Committee</option>
This allows you to select them as a default when a new user registers

I added similar lines to \administrator\components\com_content\models\config.xml

Code: Select all

<option value="31">Member</option>
<option value="32">Coach</option>
<option value="33">Committee</option>
This allows the article manager to select the correct authority level in which to display the article.

The problems
  • The menus still only appear if they are set to registered - if you set them to 'Member' 'Coach' or 'Committee' - they do not appear at all
  • The articles error with 'You are not authorised to view this content' if the article security is set to any of the new groups.
Is this sort of user group modification easier in 1.6 - should I just wait?
I have spent quite a few hours on my localhost installation trying to get this to work - my only other alternative is to create two separate websites!

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Mon Dec 14, 2009 1:52 am

Hi Iain_H,

Perhaps you are having the same problem with me as well.. seems this is the trickiest part to get through...

Can any others please share ? We really in ned of this solution for Joomla 1.5..

Thanks.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Mon Dec 14, 2009 9:36 am

Iain_H wrote:Is this sort of user group modification easier in 1.6 - should I just wait?
Yes, this will be something you can do in 1.6

Olaf
Olaf Offick - Global Moderator
learnskills.org

jjj2
Joomla! Intern
Joomla! Intern
Posts: 64
Joined: Fri Feb 13, 2009 3:36 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jjj2 » Mon Dec 14, 2009 11:56 am

ooffick wrote:
Iain_H wrote:Is this sort of user group modification easier in 1.6 - should I just wait?
Yes, this will be something you can do in 1.6

Olaf
Hi Olaf,

Thanks for following up with this thread again :)

But how long until the full stable release of v1.6 ?
And another problem is I wonder the existing components, modules, plugins & templates
will be able to work perfectly in Joomla 1.6 ?

I believe it should be able to do some tricks in Joomla 1.5 to enable this CUSTOM USER GROUP function..

Anyone else can contribute ?

Really appreciate that .

Murfix
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jan 07, 2010 12:53 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by Murfix » Thu Jan 07, 2010 12:58 am

I, as with many of you, have come to this page searching to the solution for the shortcomings of the instructions on how to add new user groups from http://docs.joomla.org/Custom_user_groups. But I could not find anything here or on the web to continue where that has left off, so I'm going to provide the path that I took and hope it's a workable solution for some of you.

After you've followed the instructions from http://docs.joomla.org/Custom_user_groups

In your template index.php file at the top add a code that is similar to this, but replace own user/group information.

Code: Select all

$user = & JFactory::getUser();
if($user->usertype == 'Sales Reps'):
	$user->aid = 3;
endif;
That checks the current logged in user's group name (name from jos_core_acl_aro_groups) and if it matches the custom group name you've added (Sales Reps) then it sets the correct aid (id from jos_groups).

That fixes the first problem that Olaf brought to attention
Olaf wrote:"The problem is that the user's aid is still set to 1 even though the user is in the new group."
If you have more than one custom user group I would suggest using a SWITCH statement instead of an IF statement. I know it's kind of a manual solution but it's the best I could come up with in this situation.

Next, in order to get your menu items to display or not display correctly based on the new aid(s) you'll have to do something like the code below.

Code: Select all

$menu = &JSite::getMenu();
$menuitems = $menu->getItems('menutype', $this->getParam('menutype'));

// go through each menu item of this menutype
foreach ($menuitems as $k => $v) {
   // check the menu item's access column against the user's $aid
   if ($v->access <= $user->get('aid', 0)) {
      // user has access to the menu item, display it...
   }
}
This might not be the best solution, but I hope it helps someone else.

JanisU
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Feb 19, 2010 3:00 pm

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by JanisU » Fri Feb 19, 2010 3:16 pm

Actually it's much simpler and you don't even need to change Joomla! core code.
It's true, that aid in session is incorrect. Aid is set by Joomla! login plugin:

Code: Select all

if ($acl->is_group_child_of($grp->name, 'Registered')      ||
		    $acl->is_group_child_of($grp->name, 'Public Backend'))    {
			$instance->set('aid', 2);
		}
As you see, whenever user is in some of 'Registered' or 'Public Backend' groups, aid is set to 2.

You can follow instructions from http://docs.joomla.org/Custom_user_groups, but set lft and rgt values in jos_core_acl_aro_groups without modifying code. After that you can correctly set user group for user in administration panel. Then you can add necessary groups to jos_groups and implement your own login plugin to map acl and Joomla! groups and activate your plugin. There's not much to change, if you copy Joomla! login plugin.

So you get necessary access control functionality and can upgrade to next Joomla! releases without any fear to lose your changes.

forestrain
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Mar 03, 2010 3:53 pm

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by forestrain » Thu Mar 04, 2010 4:10 pm

but set lft and rgt values in jos_core_acl_aro_groups without modifying code.
What do we set the lft and rgt values to?

Shannon

dhvani
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Mon Dec 21, 2009 1:09 pm

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by dhvani » Tue Mar 30, 2010 10:27 am

Hi all ,

I really need this ...

I follow all the steps stated in http://docs.joomla.org/Custom_user_groups

What i done is :

I added one user group named 'adamas' in jos_core_acl_aro_groups table.
I run the script from http://docs.joomla.org/Custom_user_groups . (Now here is one confusion should it be rebuild_tree (0 , 0) or rebuild_tree (0 , 1) )

Now i added adamas in jos_groups table.So i get it in the list of access level.

I created new user in the adamas group.
I created one menu item with the adamas access level.

Now when I login with the same user i am not getting the menu item in my menu. I logged in perfectly no errors found.

But how can i get the menu item?

Thanks all . I am also trying to search if get anything i will surely upload here but any of you get anything please tell me.

dhvani
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Mon Dec 21, 2009 1:09 pm

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by dhvani » Tue Mar 30, 2010 12:17 pm

hey one update from me i tried to use morfix solution

I added code
switch ($user->usertype) {
case 'spts':
$user->aid=4;
break;
case 'adamas':
$user->aid=3;
break;
}
in my theme's index file.

Now i have two different menu item 'Links' for adamas users and 'spts page' for spts users. Now when i logged in with adamas user i gor only adamas meanu item means 'Links' but when i try to log in with spts i see both menu items means adamas and spts.

Just for info i added adamas first and than spts.

Please solve this out if anyone has any idea

jozo2008
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Apr 12, 2010 7:28 am

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by jozo2008 » Mon Apr 12, 2010 7:55 am

Hi,
I have the same problem as dhvani. It works perfectly with one new added custom usergroup, but if I add two or more groups, both menu items will be seen when I login with second user.

Murfix also suggested this code, but I don't know where to put it. Maybe this could solve the problem:

Code: Select all

$menu = &JSite::getMenu();
$menuitems = $menu->getItems('menutype', $this->getParam('menutype'));

// go through each menu item of this menutype
foreach ($menuitems as $k => $v) {
   // check the menu item's access column against the user's $aid
   if ($v->access <= $user->get('aid', 0)) {
      // user has access to the menu item, display it...
   }
}

dhvani
Joomla! Apprentice
Joomla! Apprentice
Posts: 44
Joined: Mon Dec 21, 2009 1:09 pm

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by dhvani » Mon Apr 12, 2010 10:10 am

Yeah I also have the same question where to put Murfix's code?

I am using joomla 1.5.7

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11399
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Custom User Group DONE, but Menu Item NOT APPEARING

Post by ooffick » Mon Apr 12, 2010 10:20 am

dhvani wrote:I am using joomla 1.5.7
Please update to Joomla 1.5.15 as soon as possible.

Olaf
Olaf Offick - Global Moderator
learnskills.org


Locked

Return to “Core Hacks and Patches”