By jaypan on
I have created a menu hook. I want to have the page available to anyone with either access level A or access level B. Both have been defined in hook_perm and hook_access.
But, I keep getting errors when I try to add the second access argument. Does anybody know if this is possible, and if it is, can you show me the syntax that I use to do it? Thank you.
Comments
Well
Well without an example of the code you are trying to use the best I have is this:
From here --> http://api.drupal.org/api/function/hook_menu/6
It says the arguments are an array. Sample code from that same page shows:
So to have 2 arguments it would look like this:
That's exactly what I was
That's exactly what I was looking for. Thank you.
Contact me to contract me for D7 -> D10/11 migrations.
You're welcome
Check out the API it will help you a lot.
Very strange, I exactly do it
Very strange, I exactly do it like you said and I get SQL errors. Here is the code hook_menu:
And that are the SQL errors I get:
If I remove the second permission from the statement above, it works fine. Any ideas what is going wrong?
Not quite how it's done
Found this thread while trying to do this. Wanted to post the solution for others who stumble on this.
Despite what's said above, you can't pass multiple access arguments like this. Also, don't bother trying array(array('perm 1', 'perm 2')).
By design, the access arguments's 2nd parameter is the $account param. That's why you can't pass 2 permissions that way.
You have to use 'access calback' instead and create a function that way.
Check out this post (it's right on): http://drupal.org/node/368584#comment-1236208
Try this
'access arguments' => array('edit own blah content, edit any blah content')
Notice that the two arguments are in the same quotes separated by a comma.
It works for me.
disregard
only works for admin
bad advise
Don't use 'access arguments' => array('edit own blah content, edit any blah content'), that won't work unless you're the admin or you have a permission specifically defined in hook_perm called 'edit own blah content, edit any blah content'. The only way to accomplish this is to use your own access callback function then you can do whatever you want. karenann has the correct answer...