Changeset 50129 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 02/01/2021 10:11:46 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r49193 r50129 5399 5399 wp_send_json_success(); 5400 5400 } 5401 5402 /** 5403 * Ajax handler sends a password reset link. 5404 * 5405 * @since 5.7.0 5406 */ 5407 function wp_ajax_send_password_reset() { 5408 5409 // Validate the nonce for this action. 5410 $user_id = isset( $_POST['user_id'] ) ? (int) $_POST['user_id'] : 0; 5411 check_ajax_referer( 'reset-password-for-' . $user_id, 'nonce' ); 5412 5413 // Verify user capabilities. 5414 if ( ! current_user_can( 'edit_user', $user_id ) ) { 5415 wp_send_json_error( __( 'Cannot send password reset, permission denied.' ) ); 5416 } 5417 5418 // Send the password reset link. 5419 $user = get_userdata( $user_id ); 5420 $results = retrieve_password( $user->user_login ); 5421 5422 if ( true === $results ) { 5423 wp_send_json_success( 5424 /* translators: 1: User's display name. */ 5425 sprintf( __( 'A password reset link was emailed to %s.' ), $user->display_name ) 5426 ); 5427 } else { 5428 wp_send_json_error( $results ); 5429 } 5430 }
Note: See TracChangeset
for help on using the changeset viewer.