[ Index ]

PHP Cross Reference of Wordpress 2.9.1

title

Body

[close]

/wp-includes/ -> user.php (summary)

WordPress User API

File Size: 736 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 17 functions

  wp_signon()
  wp_authenticate_username_password()
  wp_authenticate_cookie()
  get_profile()
  get_usernumposts()
  user_pass_ok()
  get_user_option()
  update_user_option()
  get_users_of_blog()
  delete_usermeta()
  get_usermeta()
  update_usermeta()
  setup_userdata()
  wp_dropdown_users()
  _fill_user()
  sanitize_user_object()
  sanitize_user_field()

Functions
Functions that are not part of a class:

wp_signon( $credentials = '', $secure_cookie = '' )   X-Ref
Authenticate user with remember capability.

The credentials is an array that has 'user_login', 'user_password', and
'remember' indices. If the credentials is not given, then the log in form
will be assumed and used if set.

The various authentication cookies will be set by this function and will be
set for a longer period depending on if the 'remember' credential is set to
true.

param: array $credentials Optional. User info in order to sign on.
param: bool $secure_cookie Optional. Whether to use secure cookie.
return: object Either WP_Error on failure, or WP_User on success.

wp_authenticate_username_password($user, $username, $password)   X-Ref
Authenticate the user using the username and password.


wp_authenticate_cookie($user, $username, $password)   X-Ref
Authenticate the user using the WordPress auth cookie.


get_profile($field, $user = false)   X-Ref
Retrieve user data based on field.

Use get_profile() will make a database query to get the value of the table
column. The value might be cached using the query cache, but care should be
taken when using the function to not make a lot of queries for retrieving
user profile information.

If the $user parameter is not used, then the user will be retrieved from a
cookie of the user. Therefore, if the cookie does not exist, then no value
might be returned. Sanity checking must be done to ensure that when using
get_profile() that empty/null/false values are handled and that something is
at least displayed.

param: string $field User field to retrieve.
param: string $user Optional. User username.
return: string The value in the field.

get_usernumposts($userid)   X-Ref
Number of posts user has written.

param: int $userid User ID.
return: int Amount of posts user has written.

user_pass_ok($user_login, $user_pass)   X-Ref
Check that the user login name and password is correct.

param: string $user_login User name.
param: string $user_pass User password.
return: bool False if does not authenticate, true if username and password authenticates.

get_user_option( $option, $user = 0, $check_blog_options = true )   X-Ref
Retrieve user option that can be either global, user, or blog.

If the user ID is not given, then the current user will be used instead. If
the user ID is given, then the user data will be retrieved. The filter for
the result, will also pass the original option name and finally the user data
object as the third parameter.

The option will first check for the non-global name, then the global name,
and if it still doesn't find it, it will try the blog option. The option can
either be modified or set by a plugin.

param: string $option User option name.
param: int $user Optional. User ID.
param: bool $check_blog_options Whether to check for an option in the options table if a per-user option does not exist. Default is true.
return: mixed

update_user_option( $user_id, $option_name, $newvalue, $global = false )   X-Ref
Update user option with global blog capability.

User options are just like user metadata except that they have support for
global blog options. If the 'global' parameter is false, which it is by default
it will prepend the WordPress table prefix to the option name.

param: int $user_id User ID
param: string $option_name User option name.
param: mixed $newvalue User option value.
param: bool $global Optional. Whether option name is blog specific or not.
return: unknown

get_users_of_blog( $id = '' )   X-Ref
Get users for the blog.

For setups that use the multi-blog feature. Can be used outside of the
multi-blog feature.

param: int $id Blog ID.
return: array List of users that are part of that Blog ID

delete_usermeta( $user_id, $meta_key, $meta_value = '' )   X-Ref
Remove user meta data.

param: int $user_id User ID.
param: string $meta_key Metadata key.
param: mixed $meta_value Metadata value.
return: bool True deletion completed and false if user_id is not a number.

get_usermeta( $user_id, $meta_key = '')   X-Ref
Retrieve user metadata.

If $user_id is not a number, then the function will fail over with a 'false'
boolean return value. Other returned values depend on whether there is only
one item to be returned, which be that single item type. If there is more
than one metadata value, then it will be list of metadata values.

param: int $user_id User ID
param: string $meta_key Optional. Metadata key.
return: mixed

update_usermeta( $user_id, $meta_key, $meta_value )   X-Ref
Update metadata of user.

There is no need to serialize values, they will be serialized if it is
needed. The metadata key can only be a string with underscores. All else will
be removed.

Will remove the metadata, if the meta value is empty.

param: int $user_id User ID
param: string $meta_key Metadata key.
param: mixed $meta_value Metadata value.
return: bool True on successful update, false on failure.

setup_userdata($for_user_id = '')   X-Ref
Setup global user vars.

Used by set_current_user() for back compat. Might be deprecated in the
future.

param: int $for_user_id Optional. User ID to setup global data.

wp_dropdown_users( $args = '' )   X-Ref
Create dropdown HTML content of users.

The content can either be displayed, which it is by default or retrieved by
setting the 'echo' argument. The 'include' and 'exclude' arguments do not
need to be used; all users will be displayed in that case. Only one can be
used, either 'include' or 'exclude', but not both.

The available arguments are as follows:
<ol>
<li>show_option_all - Text to show all and whether HTML option exists.</li>
<li>show_option_none - Text for show none and whether HTML option exists.
</li>
<li>orderby - SQL order by clause for what order the users appear. Default is
'display_name'.</li>
<li>order - Default is 'ASC'. Can also be 'DESC'.</li>
<li>include - User IDs to include.</li>
<li>exclude - User IDs to exclude.</li>
<li>multi - Default is 'false'. Whether to skip the ID attribute on the 'select' element.</li>
<li>show - Default is 'display_name'. User table column to display. If the selected item is empty then the user_login will be displayed in parentesis</li>
<li>echo - Default is '1'. Whether to display or retrieve content.</li>
<li>selected - Which User ID is selected.</li>
<li>name - Default is 'user'. Name attribute of select element.</li>
<li>class - Class attribute of select element.</li>
</ol>

param: string|array $args Optional. Override defaults.
return: string|null Null on display. String of HTML content on retrieve.

_fill_user( &$user )   X-Ref
Add user meta data as properties to given user object.

The finished user data is cached, but the cache is not used to fill in the
user data for the given object. Once the function has been used, the cache
should be used to retrieve user data. The purpose seems then to be to ensure
that the data in the object is always fresh.

param: object $user The user data object.

sanitize_user_object($user, $context = 'display')   X-Ref
Sanitize every user field.

If the context is 'raw', then the user object or array will get minimal santization of the int fields.

param: object|array $user The User Object or Array
param: string $context Optional, default is 'display'. How to sanitize user fields.
return: object|array The now sanitized User Object or Array (will be the same type as $user)

sanitize_user_field($field, $value, $user_id, $context)   X-Ref
Sanitize user field based on context.

Possible context values are:  'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The
'display' context is used by default. 'attribute' and 'js' contexts are treated like 'display'
when calling filters.

param: string $field The user Object field name.
param: mixed $value The user Object value.
param: int $user_id user ID.
param: string $context How to sanitize user fields. Looks for 'raw', 'edit', 'db', 'display',
return: mixed Sanitized value.



Generated: Fri Jan 8 00:19:48 2010 Cross-referenced by PHPXref 0.7