How do I restrict the custom urls to a specific role?
How do I restrict the custom urls (listed below) to a specific role? //hook_menu() function custom_subscription_menu() { $items = array(); $items['admin/store/free_subscription'] = array( 'title' => 'free_subscription_form', 'description' => 'free_subscription_form', 'page callback' => 'free_subscription_form', 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['admin/store/process_free_subscription'] = array( 'title' => 'process_free_subscription', 'description' => 'process_free_subscription', 'page callback' => 'process_free_subscription', 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); return $items; }
Hi Change your access callback from TRUE and add the name of the permission as an access argument, don't use a role - as these change by site - use a permission instead. Eg $items['admin/store/free_subscription'] = array( 'title' => 'free_subscription_form', 'description' => 'free_subscription_form', 'page callback' => 'free_subscription_form', 'access arguments' => array('some permission name'), 'type' => MENU_CALLBACK, ); On Thu, 2011-03-10 at 16:06 -0500, John Mitchell wrote:
How do I restrict the custom urls (listed below) to a specific role? }
On Thursday 10 March 2011, John Mitchell wrote:
How do I restrict the custom urls (listed below) to a specific role?
Set 'access callback' to a function and do it there.
//hook_menu()
function custom_subscription_menu() { $items = array();
$items['admin/store/free_subscription'] = array( 'title' => 'free_subscription_form', 'description' => 'free_subscription_form', 'page callback' => 'free_subscription_form', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );
$items['admin/store/process_free_subscription'] = array( 'title' => 'process_free_subscription', 'description' => 'process_free_subscription', 'page callback' => 'process_free_subscription', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );
return $items; }
-- ----------------- Bob Hutchinson Midwales dot com -----------------
I happen to have a handy link where I somewhat thoroughly went through this. How do you link to SO without it looking like point farming? Not linking your own answers? http://stackoverflow.com/questions/5124584/how-to-use-hook-menu-alter-to-man... On Mar 10, 2011 4:23 PM, "Bob Hutchinson" <hutchlists@midwales.com> wrote:
On Thursday 10 March 2011, John Mitchell wrote:
How do I restrict the custom urls (listed below) to a specific role?
Set 'access callback' to a function and do it there.
//hook_menu()
function custom_subscription_menu() { $items = array();
$items['admin/store/free_subscription'] = array( 'title' => 'free_subscription_form', 'description' => 'free_subscription_form', 'page callback' => 'free_subscription_form', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );
$items['admin/store/process_free_subscription'] = array( 'title' => 'process_free_subscription', 'description' => 'process_free_subscription', 'page callback' => 'process_free_subscription', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );
return $items; }
-- ----------------- Bob Hutchinson Midwales dot com -----------------
participants (4)
-
Adam B. Ross -
Bob Hutchinson -
John Mitchell -
Lee Rowlands