Adding custom access condition to menu item.
As Drupal is hailed as good CMS if you want to alter any existing thing.
The hook architecture of drupal makes it possible to alter any thing.
You can also add custom acess callback for any menu item.
To add custom menu access callback you can user hook_menu_alter() function.
As per the documentation this hook Alter the data being saved to the {menu_router} table after hook_menu is invoked.
This hook is invoked by menu_router_build(). The menu definitions are passed in by reference.
Each element of the $items array is one item returned by a module from hook_menu. Additional items may be added, or existing items altered.
Alter the user/%user/edit access callback
/** * Implements hook_menu_alter(). */ function YOURHOOKNAME_menu_alter(&$items) { // Define the new accesscallback $items['user/%user/edit']['access callback'] = 'user_access_profile_callback'; } function user_access_profile_callback() { //Check your condition and restriction //Return true if condition successful. //Else false }
Comments
make your own d... (not verified)
Sun, 01/12/2014 - 18:26
Permalink
Adding custom access condition to menu item. | Mohit Aghera
Hi! Would you mind if I share your blog with my myspace group?
There's a lot of people that I think would really appreciate
your content. Please let me know. Many thanks
mohit.aghera
Sun, 03/30/2014 - 06:41
Permalink
Ofcourse you can share it..
You can share it on any social media. It is opensource. The more you share, the more you get and learn :)
Happy sharing..
Brucewayne (not verified)
Tue, 02/18/2014 - 07:29
Permalink
Amazing
You spared me a lot of time by giving this information. The hook architecture is quite useful. I never knew that there is an option to access callback from any menu item. Thank you so much for sharing this valuable info.
windows vista service pack 3
kendi102 (not verified)
Tue, 06/03/2014 - 08:44
Permalink
adding custom access
Thanks for such a knowledgeable information..that information is very useful..
soundcloud download
buysoundcloudnow.com
quest protein bars (not verified)
Mon, 08/25/2014 - 21:47
Permalink
Add new comment | Mohit Aghera
I got this website from my buddy who told me about this site and at the moment this
time I am visiting this web site and reading very informative content here.
Add new comment