WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#35859 new defect (bug)

get_edit_user_link should always return the edit user link even if the given ID is that of the current user

Reported by: jancbeck Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Users Keywords: 2nd-opinion
Focuses: administration Cc:

Description

In my scenario a user action triggers an email that is sent to the site admin that contains a link to edit that users profile. When I'm using the function as follows

<?php
wp_mail( get_option('admin_email'), 'User needs help', get_edit_user_link( get_current_user_id() ) );

the email only contains a link to http://example.com/wp-admin/profile.php which of course isn't very helpful in that context.

The expected behavior to me is that the URL returned is always pointing to that specific user that I used as a function argument and I can use the link in any context: http://example.com/wp-admin/user-edit.php?user_id=19

Change History (3)

#1 @ericlewis
2 years ago

  • Component changed from Administration to Users
  • Keywords 2nd-opinion added

#2 @swissspidy
2 years ago

wp-admin/user-edit.php?user_id=<current_user_id> is equal to wp-admin/profile.php, so that's not a big deal.

In get_edit_user_link(), get_edit_profile_url() is currently used to get the URL to the users' profile. This function uses get_dashboard_url() to get the correct URL based on the user's current/active blog on multisite. That means a 1:1 replacement is probably not really possible.

Core uses get_edit_user_link() only in a few places: the users list tables, the comments template and the edit profile form itself.

@jancbeck I think for now you should just use add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) )

#3 @obenland
2 years ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.