wp_set_current_user [ WordPress Function ]
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Changes the current user by ID or name.
Set $id to null and specify a name if you do not know a user's ID.
Some WordPress functionality is based on the current user and not based on the signed in user. Therefore, it opens the ability to edit and perform actions on users who aren't signed in.
Source
<?php
function wp_set_current_user($id, $name = '') {
global $current_user;
if ( isset( $current_user ) && ( $current_user instanceof WP_User ) && ( $id == $current_user->ID ) )
return $current_user;
$current_user = new WP_User( $id, $name );
setup_userdata( $current_user->ID );
do_action('set_current_user');
return $current_user;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/wp set current user « WordPress Codex
Description. This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead. Changes the current user by ID or ...
codex.wordpress.org - Docs for page pluggable.php
wp_set_current_user (line 27). Changes the current user by ID or name. Set $id to null and specify a name if you do not know a user's ID. Some WordPress ...
phpdoc.wordpress.org - WordPress › Support » wp_set_current_user not logging in fully
For a few days I've been struggling with auto login for users - wp_set_auth_cookie - wp_set_current_user. The symptoms where the current WordPress page ...
wordpress.org - WordPress › Support » Tags — wp_set_current_user
(forgot?) Register · WordPress › Support » wp_set_current_user ... [resolved] wp_set_current_user not logging in fully, 1, MikaelT, 1 month. Login to WordPress ...
wordpress.org