Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#14787 closed enhancement (fixed)

Introduce get_edit_user_link()

Reported by: scribu's profile scribu Owned by: ryan's profile ryan
Milestone: 3.5 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:

Description

We should have a function for this, similar to get_edit_post_link(), get_edit_comment_link() etc.

Attachments (4)

get_edit_user_link.patch (935 bytes) - added by Ornani 14 years ago.
14787.diff (5.3 KB) - added by scribu 14 years ago.
14787.2.diff (590 bytes) - added by SergeyBiryukov 13 years ago.
14787.3.diff (472 bytes) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (14)

#1 @Ornani
14 years ago

  • Keywords needs-testing reporter-feedback added

I've made a patch but haven't tested it.

@scribu
14 years ago

#2 @scribu
14 years ago

  • Keywords reporter-feedback removed

I also started to make a patch, even before opening this ticket, but didn't have time to complete it.

Posting it now to avoid duplicate effort. See 14787.diff

#3 @nacin
14 years ago

  • Keywords has-patch added; needs-testing removed
  • Milestone changed from Awaiting Review to Future Release

#4 @nacin
13 years ago

  • Milestone changed from Future Release to 3.5

There's a get_edit_user_link() in #20307 as well.

#5 @georgestephanis
13 years ago

Patch merging this with #20307 is in ... you guessed it ... #20307

#6 @ryan
13 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [21364]:

Introduce get_edit_user_link(). Props scribu, georgestephanis, johnbillion. fixes #14787 see #20307

#7 @SergeyBiryukov
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Since [21364], if you try to log in as a subscriber, you'll get a blank screen.

Here's a rundown of what happens:

  1. In wp-login.php, get_edit_user_link() is called:
    http://core.trac.wordpress.org/browser/trunk/wp-login.php?rev=21421#L628
  2. In get_edit_user_link(), get_current_user_id() and current_user_can() are called: http://core.trac.wordpress.org/browser/trunk/wp-includes/link-template.php?rev=21421#L1059
  3. Since cookies are not set yet, both functions fail and an empty string is returned.
  4. There's nowhere to redirect, so exit() in line 632 leaves you with a blank screen.
  5. If you refresh the page, the user's profile appears as expected, since cookies are already set and wp_get_current_user() returns the actual user.

14787.2.diff fixes the issue by calling wp_set_current_user() before trying to get the profile link in wp-login.php. We could instead pass $user->ID to get_edit_user_link() to avoid get_current_user_id(), but current_user_can() would fail anyway.

An alternative would be to revert to admin_url( 'profile.php' ).

#8 @georgestephanis
13 years ago

Or just change the default for the value passed to be an empty string, in which case, get_current_user_id() == $user_id would evaluate to true, and return profile.php ... no?

EDIT: Ignore me, I didn't look at the trunk version, I was looking at 14787.diff

Last edited 13 years ago by georgestephanis (previous) (diff)

#9 @SergeyBiryukov
13 years ago

14787.3.diff brings back admin_url() in wp-login.php (as per nacin's suggestion).

#10 @ryan
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In [21507]:

Use admin_url() instead of get_edit_user_link() in wp-login.php since cookies are not yet set. Props SergeyBiryukov. fixes #14787

Note: See TracTickets for help on using tickets.