Run prettier on all *.md files
```
prettier '{app,source}/**/**.md' --write
```
This commit is contained in:
parent
a3ceeaf0f3
commit
85a10c545b
170 changed files with 5127 additions and 2282 deletions
|
|
@ -9,7 +9,10 @@ tags:
|
|||
- drupal-planet
|
||||
- php
|
||||
---
|
||||
I see this regularly when working on Drupal sites when someone wants to check whether the current user is logged in to Drupal (authenticated) or not (anonymous).
|
||||
|
||||
I see this regularly when working on Drupal sites when someone wants to check
|
||||
whether the current user is logged in to Drupal (authenticated) or not
|
||||
(anonymous).
|
||||
|
||||
```language-php
|
||||
global $user;
|
||||
|
|
@ -27,7 +30,9 @@ if (!$user->uid) {
|
|||
}
|
||||
```
|
||||
|
||||
The better way to do this is to use the [user_is_logged_in()](http://api.drupal.org/api/drupal/modules!user!user.module/function/user_is_logged_in/7) function.
|
||||
The better way to do this is to use the
|
||||
[user_is_logged_in()](http://api.drupal.org/api/drupal/modules!user!user.module/function/user_is_logged_in/7)
|
||||
function.
|
||||
|
||||
```language-php
|
||||
if (user_is_logged_in()) {
|
||||
|
|
@ -35,9 +40,12 @@ if (user_is_logged_in()) {
|
|||
}
|
||||
```
|
||||
|
||||
This returns a boolean (TRUE or FALSE) depending or not the user is logged in. Essentially, it does the same thing as the first example, but there's no need to load the global variable.
|
||||
This returns a boolean (TRUE or FALSE) depending or not the user is logged in.
|
||||
Essentially, it does the same thing as the first example, but there's no need to
|
||||
load the global variable.
|
||||
|
||||
A great use case for this is within a `hook_menu()` implementation within a custom module.
|
||||
A great use case for this is within a `hook_menu()` implementation within a
|
||||
custom module.
|
||||
|
||||
```language-php
|
||||
/**
|
||||
|
|
@ -54,4 +62,7 @@ function mymodule_menu() {
|
|||
}
|
||||
```
|
||||
|
||||
There is also a [user_is_anonymous()](http://api.drupal.org/api/drupal/modules!user!user.module/function/user_is_anonymous/7) function if you want the opposite result. Both of these functions are available in Drupal 6 and higher.
|
||||
There is also a
|
||||
[user_is_anonymous()](http://api.drupal.org/api/drupal/modules!user!user.module/function/user_is_anonymous/7)
|
||||
function if you want the opposite result. Both of these functions are available
|
||||
in Drupal 6 and higher.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue