2

I've written a question and gotten an answer. The is fine but not fulfill my requirements. The question is below:

It will be helpful, if anyone explain the full meaning of the string 'access content' because I've not found 'access content' string on '/admin/people/permissions' page. On the other hand, if I use following code, it will be work.

function custom_menu_menu(){
    $items = array();
      $items ['status'] = array(
        'title' => 'My Status',
        'menu_name' => 'main_menu',
        'page callback' => 'status_page',
        'access arguments' => array('access content'),
      );
    return $items;
}

/*
  *Definition of the menu callback function.
  */
function status_page() {
    return 'Hello world!';
}

My Questions:

  1. Is 'access content' a 'permission string'? if answer is 'yes' then please explain how does it works? [note: it is not listed in '/admin/people/permissions' page. So, How determinate that user's rules has this permission]
  2. What is the meaning of 'access content' permission? example: 'Page: Create new content' permission means if user has this permission then user can create 'Page' content but if user has 'access content' permission then what can do user on this link page.
3

Read: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7

  1. 'access content' means 'Node: View published content' on permission list. Check this link for list of permissions provided by node module: https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_permission/7

  2. 'access content' will be passed as a first argument to user_access() which is default access callback for new menu items. You can change default access callback like this:

    function custom_menu_menu(){
      $items = array();
      $items ['status'] = array(
        'title' => 'My Status',
        'menu_name' => 'main_menu'
        'page callback' => 'status_page',
        'access callback' => 'custom_menu_access_callback',
        'access arguments' => array('access content', 'something else'),
      );
      return $items;
    }
    
    function custom_menu_access_callback($arg1, $arg2) {
      // arg1: access content
      // arg2: something else
      // if this function returns TRUE user will get access to page callback
      // if this function returns FALSE user won't get access to page callback
    }
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.