List Info

Thread: Re: Tell if current page is viewable by anonymous users




Re: Tell if current page is viewable by anonymous users
country flaguser name
Belgium
2008-02-19 11:55:59
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 

Re: Tell if current page is viewable by anonymous users
user name
2008-02-19 12:41:51
Does the module itself provide the page?

On Feb 19, 2008 1:40 PM, Jerad Bitner <sirkitreegmail.com> wrote:
> function myfunctionname() {
>   global $user;
>   if ($user->uid == 0) {
>     // user in anon
>
>   }
> }
>
> On Feb 19, 2008 1:08 PM, Salgar <salgargmx.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
> >
>

Re: Tell if current page is viewable by anonymous users
country flaguser name
Germany
2008-02-19 12:50:24
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

Re: Tell if current page is viewable by anonymous users
country flaguser name
Germany
2008-02-19 12:08:55
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

Re: Tell if current page is viewable by anonymous users
user name
2008-02-19 12:40:58
function myfunctionname() {
  global $user;
  if ($user->uid == 0) {
    // user in anon
  }
}

On Feb 19, 2008 1:08 PM, Salgar <salgargmx.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
>

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )