Re: [development] Tell if current page is viewable by anonymous users
You can use function menu_valid_path()
Hi,
is there a way to determine (in a module) whether the current page can be viewed by anonymous users?
I've found user_access() and drupal_anonymous_user() - but this would require a node. Do all "public" pages have a node?
Kind regards,
Salgar
Petr Vacha wrote:
You can use function menu_valid_path()
This checks whether the current user can access the current page - not whether anonymous users may access it. :'( Kind regards, Salgar
function myfunctionname() { global $user; if ($user->uid == 0) { // user in anon } } On Feb 19, 2008 1:08 PM, Salgar <salgar@gmx.net> wrote:
Petr Vacha wrote:
You can use function menu_valid_path()
This checks whether the current user can access the current page - not whether anonymous users may access it. :'(
Kind regards,
Salgar
Does the module itself provide the page? On Feb 19, 2008 1:40 PM, Jerad Bitner <sirkitree@gmail.com> wrote:
function myfunctionname() { global $user; if ($user->uid == 0) { // user in anon
} }
On Feb 19, 2008 1:08 PM, Salgar <salgar@gmx.net> wrote:
Petr Vacha wrote:
You can use function menu_valid_path()
This checks whether the current user can access the current page - not whether anonymous users may access it. :'(
Kind regards,
Salgar
Jerad Bitner wrote:
Does the module itself provide the page? No, the module just display ads. But they should only appear on a page if anonymous users can also view this page.
So if a user is logged in and visits a page which is also accessible for everyone - he sees ads. If he visits a page which is not accessible for anonymous users - he sees no ads. So I need something like: may_access(drupal_get_path_alias($_GET['q']), drupal_anonymous_user()) Kind regards, Salgar
participants (3)
-
Jerad Bitner -
Petr Vacha -
Salgar