This package contains two classes:
WordPress does not set the current user until right before the
init hook. This can be problematic sometimes.
Sometimes, you may need to set the current user before WordPress is ready to set the current user (e.g., on
registered_post_type hooks). So this class enables you to do that.
For the current user:
$the_current_user = \WPS\User\CurrentUser::get_instance()->get_current_user();
Determining whether a user is the current user by User ID, email or username:
// By ID. \WPS\User\CurrentUser::get_instance()->is_current_user( 2 ) // By Email. \WPS\User\CurrentUser::get_instance()->is_current_user( 'firstname.lastname@example.org' ) // By username/user login \WPS\User\CurrentUser::get_instance()->is_current_user( 'myusername' )
You can also use this to set "super" users.
$super_users = array( 'username1', 'email@example.com', 3, ); \WPS\User\CurrentUser::get_instance()->is_current_a_super_user()
Sometimes it is good to hide a user from other users so that user won't be deleted or modified accidentally by another administrator.
To hide a user or set of users:
\WPS\User\HideUser::get_instance( array( 'hidden_user1', 'hidden_user2', ) );