Question: So, I have a widget that I only want to show it to the page author.

I used the following logic: is\_author()

However it does not seem to work (it shows non-author)

Am I using this logic right?

Any suggestions?

Thank you

Answer: 
is\_author() is only for Archive pages. 
Quote from the Codex: 

> 
> is\_author() checks if an Author archive page is being displayed
> 
> 
> 

So viewing a single Post or Page isn't going to get a TRUE from is\_author().

I think you'll want something more like this:

```
global $post,$current_user; // get the global variables to check
get_currentuserinfo();  // get current user info
// Now check if the author of this post is the same as the current logged in user
if ($post->post_author == $current_user->ID) {
   // do code here
}

```

I hope this helps. :)

EDIT #1:
Shortened code version.

```
// Check if the author of this post is the same as the current logged in user
if ( $post->post_author == get_current_user_id() ) {
   // do code here
}

```
You can use:

```
$obj = get_queried_object();
$user_id = get_current_user_id();

// check if page's post author is same as logged in user
if (isset($obj->post_author) && $obj->post_author == $user_id) {
    // ... do your stuff here
}

```

With `get_queried_object` function you get object of the current page. As it's requested that page should be of "page" type you'll get WP\_Post object of the current page (post\_type = 'page').

The `get_current_user_id` is self-explanatory.

So if both match, you'll get code running for current user which is creator of the page.

You can also place a check that queried object is 'page':

```
if ($obj instanceof WP_Post && $obj->post_type == 'page') {
    // ...
}

```