How to use/show different path alias of same URL according to user roles? Hi I have set URL alias of for node add from path like below :


  
  node/add/my_content_type =  addlink
  node/add/my_content_type  = suggestion
  


When user is logged-in we make access of node add form via this URL:


  www.example.com/addlink


Now for not logged-in user we want users to use node add from via below URL:


  www.example.com/suggestion


I am trying with rules on event "Initialize drupal" then checking path and roles and trying to redirect but not able to achieve that.

Please suggest is that possible to make it happen in some way!

Thanks!
The ensure the right path is used when displaying links, you need to implement hook_url_outbound_alter() in a custom module.

/**
 * Implement hook_url_outbound_alter().
 */
function MODULE_url_outbound_alter(&amp;$path, &amp;$options, $original_path) {
  if ($path == 'node/add/my_content_type') {
    $path = user_is_logged_in() ? 'addlink' : 'suggestion';
  }
}


Ensuring the right path is always used can be achieved with a hook_menu_alter(). There, you can alter the page callback for node/add/my_content_type. And in your callback, check whether the user is accessing the page using the expected path.

/**
 * Implements hook_menu_alter().
 */
function MODULE_hook_menu_alter(&amp;$items) {
   $type_url_str = str_replace('_', '-', 'my_content_type');
   $items[['node/add/' . $type_url_str]['page callback'] = 'MODULE_my_content_type_add';
}

/**
 * Page callback for the add new My Content node page.
 *
 * @see MODULE_hook_menu_alter
 */
function MODULE_my_content_type_add($type) {
  $expected_path = user_is_logged_in() ? 'addlink' : 'suggestion';
  if (current_path() != $expected_path) {
    drupal_goto($expected_path);
  }
  else {
    return node_add($type);
  }
}


If you site use multiple language with prefix language selector, then current_path() will also contains the language prefix whch need to be accounted for in your code.