get_edit_user_link

Retrieves the edit user link.

Description

(string) get_edit_user_link( (null) $user_id = null ); 

Returns (string)

URL to edit user page or empty string.

Parameters (1)

0. $user_id — Optional. (null) => null
User ID. Defaults to the current user.

Usage

  1. if ( !function_exists( 'get_edit_user_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. User ID. Defaults to the current user. 
  5. $user_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_edit_user_link($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function get_edit_user_link( $user_id = null ) { 
  2. if ( ! $user_id ) 
  3. $user_id = get_current_user_id(); 
  4.  
  5. if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) 
  6. return ''; 
  7.  
  8. $user = get_userdata( $user_id ); 
  9.  
  10. if ( ! $user ) 
  11. return ''; 
  12.  
  13. if ( get_current_user_id() == $user->ID ) 
  14. $link = get_edit_profile_url( $user->ID ); 
  15. else 
  16. $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); 
  17.  
  18. /** 
  19. * Filters the user edit link. 
  20. * @since 3.5.0 
  21. * @param string $link The edit link. 
  22. * @param int $user_id User ID. 
  23. */ 
  24. return apply_filters( 'get_edit_user_link', $link, $user->ID );