The blog route blog/%user_uid_optional
route provided by the blog module performs a few checks in blog_page_user_access()
:
// The visitor must be able to access the site's content.
// For a blog to 'exist' the user must either be able to
// create new blog entries, or it must have existing posts.
return $account->uid &&
user_access('access content') &&
(user_access('create blog content', $account) ||
_blog_post_exists($account));
The $account->uid
part of the conditional check will preclude access to blog/0 even if anonymous users can create blogs posts.
A module evoking hook_menu_alter()
you can override this route behavior by providing your own access callback that excludes the $account->uid
check:
/**
* Implements hook_menu_alter().
*/
function MYMODULE_menu_alter(&$items) {
if (isset($items['blog/%user_uid_optional'])) {
$items['blog/%user_uid_optional']['access callback'] = 'MYMODULE_blog_page_user_access';
}
}
function MYMODULE_blog_page_user_access($account) {
return user_access('access content') && (user_access('create blog content', $account) || _blog_post_exists($account));
}