wp_ajax_save_wporg_username

Ajax handler for saving the user's WordPress.org username.

Description

wp_ajax_save_wporg_username(); 

Usage

  1. if ( !function_exists( 'wp_ajax_save_wporg_username' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_save_wporg_username(); 
  7.  

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_save_wporg_username() { 
  2. if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) { 
  3.  
  4. check_ajax_referer( 'save_wporg_username_' . get_current_user_id() ); 
  5.  
  6. $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false; 
  7.  
  8. if ( ! $username ) { 
  9.  
  10. wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) );