Title: get_edit_user_link
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_edit_user_link( int $user_id = null ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#wp--skip-link--target)

Retrieves the edit user link.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#parameters)󠁿

 `$user_id`intoptional

User ID. Defaults to the current user.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#return)󠁿

 string URL to edit user page or empty string.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#source)󠁿

    ```php
    function get_edit_user_link( $user_id = null ) {
    	if ( ! $user_id ) {
    		$user_id = get_current_user_id();
    	}

    	if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
    		return '';
    	}

    	$user = get_userdata( $user_id );

    	if ( ! $user ) {
    		return '';
    	}

    	if ( get_current_user_id() === $user->ID ) {
    		$link = get_edit_profile_url( $user->ID );
    	} else {
    		$link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) );
    	}

    	/**
    	 * Filters the user edit link.
    	 *
    	 * @since 3.5.0
    	 *
    	 * @param string $link    The edit link.
    	 * @param int    $user_id User ID.
    	 */
    	return apply_filters( 'get_edit_user_link', $link, $user->ID );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/link-template.php#L1740)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/link-template.php#L1740-L1770)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘get_edit_user_link’, string $link, int $user_id )](https://developer.wordpress.org/reference/hooks/get_edit_user_link/)

Filters the user edit link.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#related)󠁿

| Uses | Description | 
| [get_edit_profile_url()](https://developer.wordpress.org/reference/functions/get_edit_profile_url/)`wp-includes/link-template.php` |

Retrieves the URL to the user’s profile editor.

  | 
| [self_admin_url()](https://developer.wordpress.org/reference/functions/self_admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for either the current site or the network depending on context.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [get_userdata()](https://developer.wordpress.org/reference/functions/get_userdata/)`wp-includes/pluggable.php` |

Retrieves user info by user ID.

  | 
| [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)`wp-includes/functions.php` |

Retrieves a modified URL query string.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_current_user_id()](https://developer.wordpress.org/reference/functions/get_current_user_id/)`wp-includes/user.php` |

Gets the current user’s ID.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#)

| Used by | Description | 
| [WP_MS_Users_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_ms_users_list_table/handle_row_actions/)`wp-admin/includes/class-wp-ms-users-list-table.php` |

Generates and displays row action links.

  | 
| [WP_MS_Users_List_Table::column_username()](https://developer.wordpress.org/reference/classes/wp_ms_users_list_table/column_username/)`wp-admin/includes/class-wp-ms-users-list-table.php` |

Handles the username column output.

  | 
| [WP_Users_List_Table::single_row()](https://developer.wordpress.org/reference/classes/wp_users_list_table/single_row/)`wp-admin/includes/class-wp-users-list-table.php` |

Generates HTML for a single row on the users.php admin panel.

  | 
| [attachment_submitbox_metadata()](https://developer.wordpress.org/reference/functions/attachment_submitbox_metadata/)`wp-admin/includes/media.php` |

Displays non-editable attachment metadata in the publish meta box.

  | 
| [wp_admin_bar_edit_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_menu/)`wp-includes/admin-bar.php` |

Provides an edit link for posts and terms.

  | 
| [wp_prepare_attachment_for_js()](https://developer.wordpress.org/reference/functions/wp_prepare_attachment_for_js/)`wp-includes/media.php` |

Prepares an attachment post object for JS, where it is expected to be JSON-encoded and fit into an Attachment model.

  | 
| [comment_form()](https://developer.wordpress.org/reference/functions/comment_form/)`wp-includes/comment-template.php` |

Outputs a complete commenting form for use within a template.

  |

[Show 2 more](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.5.0](https://developer.wordpress.org/reference/since/3.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#comment-content-1143)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_edit_user_link/#comment-1143)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_edit_user_link%2F%23comment-1143)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_edit_user_link%2F%23comment-1143)
 4.  **Basic Example**
 5.  Get the edit user link for the user currently viewing the page.
 6.      ```php
         <a href="<?php echo get_edit_user_link(); ?>">name</a>
         ```
     
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_edit_user_link%2F%3Freplytocom%3D1143%23feedback-editor-1143)
 8.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/get_edit_user_link/?output_format=md#comment-content-1144)
 9.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_edit_user_link/#comment-1144)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_edit_user_link%2F%23comment-1144)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_edit_user_link%2F%23comment-1144)
 11. **Each editor’s link**
 12. Get a link for each editor in the database
 13.     ```php
         $user = new WP_User_Query( array(
           'role' => 'editor'
         ));
     
         $editor = $users->get_results();
     
         foreach( $editor as $e ){
           $userdata = get_userdata( $e->ID );
           echo '<a href="'. get_edit_user_link( $e->ID ) .'">'. esc_attr( $userdata->user_nicename ) .'</a>';
         }
         ```
     
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_edit_user_link%2F%3Freplytocom%3D1144%23feedback-editor-1144)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_edit_user_link%2F)
before being able to contribute a note or feedback.