Skip to content

Instantly share code, notes, and snippets.

@AnadarProSvcs
Last active December 19, 2023 18:57
Show Gist options
  • Save AnadarProSvcs/76c68762398dae0c4900617f792e8586 to your computer and use it in GitHub Desktop.
Save AnadarProSvcs/76c68762398dae0c4900617f792e8586 to your computer and use it in GitHub Desktop.
WP_User the WordPress User object common properties and functions #wordpress

WordPress WP_User Object Reference

Properties of WP_User

  • ID: Unique identifier for the user.
  • user_login: The user's login name.
  • user_pass: The user's password (hashed).
  • user_nicename: The URL-friendly user name.
  • user_email: The user's email address.
  • user_url: The user's website URL.
  • user_registered: The date and time when the user registered.
  • user_activation_key: Activation key for the user.
  • user_status: The status of the user.
  • display_name: The display name of the user.
  • roles: Array of the user's roles.
  • cap_key: Capability key.
  • caps: Array of the user's capabilities.
  • allcaps: Array of all capabilities the user has, including inherited ones.
  • filter: Filter context applied on data.

WordPress User Functions

  • get_userdata(): Retrieves the userdata of a user by ID.
  • get_user_by(): Retrieves user data given a field and value.
  • wp_insert_user(): Inserts or updates a user in the database.
  • wp_update_user(): Updates a user's data.
  • wp_delete_user(): Deletes a user from the database.
  • wp_create_user(): Creates a new user with a specified role.
  • wp_set_password(): Sets the password for a user.
  • get_user_meta(): Retrieves a user's metadata.
  • add_user_meta(): Adds metadata for a user.
  • update_user_meta(): Updates a user's metadata.
  • delete_user_meta(): Deletes a user's metadata.
  • is_user_logged_in(): Checks if the current visitor is a logged-in user.
  • current_user_can(): Checks if the current user has a specific capability.
  • get_current_user_id(): Retrieves the ID of the current user.
  • wp_get_current_user(): Retrieves the current user's data.
  • user_can(): Checks if a user has a specific capability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment