Opened 14 years ago
Closed 12 years ago
#17912 closed defect (bug) (duplicate)
WordPress not "realizing" that I'm an author on 404 error page
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2 |
Component: | General | Keywords: | has-patch needs-testing dev-feedback |
Focuses: | Cc: |
Description
Hello.
I have a link in my header that only appears if a user is an author or higher; it's the new post link. The link appears on all pages when I'm logged in as an author, except when there is a 404 error. On a 404 error page, the link doesn't display (almost as if WordPress thinks I'm not an author, just a subscriber).
WordPress does still pickup that I'm logged in, however, as the link below the new post link is to logout (and it displays that).
Attachments (2)
Change History (17)
#2
@
14 years ago
<?php if ( is_user_logged_in() && current_user_can('edit_post') ) {?> <div id="settings"> <a href="#" class="button"> <span class="txt"> <div style="float:left;margin-right:5px"> <?php global $userdata; get_currentuserinfo(); echo get_avatar( $userdata->ID, '16' ); ?> </div> <span style="float:left"> <?php global $current_user; get_currentuserinfo(); echo $current_user->user_login . "\n"; ?> </span> </span> <span class="ar">▼</span> </a> <div class="menu"> <ul> <li><a style="text-decoration:none" href="/wp-admin/post-new.php">New Post</a></li> [SNIP] <?php } ?>
#5
@
14 years ago
- Keywords close reporter-feedback added
It seems to me that this code appears in one of your theme's files that isn't included on a 404 when 404.php will be loaded. If this is the case then there is nothing that WordPress can do.
#6
@
14 years ago
I'm a bit confused on that. I'm loading that code in the header.php file, meaning that it should still load on a 404 page, correct? Or do I need to copy the exact header.php file into 404.php?
#7
@
14 years ago
I tried placing the following code directly in the 404.php and it still didn't work...
<?php if( current_user_can('edit_post') ) : ?> <a href="<?php bloginfo("url")?>/wp-admin/post-new.php"><?php _e('New Post', ''); ?></a> <?php endif; ?>
#9
@
14 years ago
- Keywords has-patch dev-feedback added
This patch does the trick, but I would love to hear some feedback about the potential problems with the if ( ! $post_type) thing
#10
@
14 years ago
- Cc be.roth@… added
- Keywords needs-review added; has-patch dev-feedback removed
Please see next comment.
#11
@
14 years ago
- Keywords has-patch needs-testing dev-feedback added; needs-review removed
The patch does the trick - I was applying it around line 830, but you need to apply around 880. Thanks for solving. Now, seems like a few tests have to be run and that's that.
#12
@
14 years ago
Yeah the patch does work, but I have serious doubts about the conditional line and unless one of the devs who knows well this particular line of code gives it a go, I seriously doubt it will make the core
#13
@
12 years ago
When I am viewing a 404 page with the code above in my header.php file I run into a few problem.
$args = array_slice( func_get_args(), 2 );
Grabs any extra parameters. Later in the code it uses $args[0] without even checking that it is set. This causes a ton of undefined index and later does
$post = get_post( $args[0] );
and assumes $post is post data when it is actually an empty array, causing even more undefined index notices.
My patch just breaks out when they are not set. No need for conditional checks when there are other notices anyways.
#15
@
12 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
current_user_can('edit_post')
is incorrect. edit_post is a meta capability, requiring a second argument. This is a duplicate of #13905 — if the post doesn't exist, then breaking out and requiring no cap seems like the wrong thing to do.
Please post the code that generates that link. Otherwise, there's not much we can do.