\um\coreUser

Class User

Summary

Methods
Properties
Constants
__construct()
is_metakey_banned()
avoid_banned_keys()
flush_um_count_users_transient_update()
flush_um_count_users_transient_add()
flush_um_count_users_transient_delete()
on_delete_usermeta()
on_update_usermeta()
delete_user_handler()
check_membership()
add_um_role_existing_user()
add_um_role_wpmu_new_user()
get_profile_slug()
get_profile_link()
generate_user_hash()
generate_profile_slug()
user_register_via_admin()
profile_update()
profile_form_additional_section()
secondary_role_field()
toArray()
get_cached_data()
setup_cache()
remove_cache()
remove_cache_all_users()
set()
reset()
auto_login()
set_registration_details()
set_last_login()
set_status()
assign_secretkey()
maybe_generate_password_reset_key()
password_reset()
password_changed()
approve()
email_pending()
pending()
reject()
deactivate()
delete()
get_role()
update_usermeta_info()
delete_meta()
get_admin_actions()
is_profile_noindex()
is_private_profile()
is_approved()
is_private_case()
update_files()
update_profile()
user_has_metadata()
user_exists_by_name()
user_exists_by_id()
user_exists_by_hash()
user_exists_by_custom_meta()
user_exists_by_email_as_username()
set_gravatar()
add_activation_placeholder()
add_activation_replace_placeholder()
get_pending_users_count()
remove_cached_queue()
$previous_data
$id
$usermeta
$data
$profile
$cannot_edit
$deleted_user_id
$banned_keys
$preview
$send_mail_on_delete
$update_user_keys
$target_id
$updating_process
$cached_user
No constants found
No protected methods found
No protected properties found
N/A
clean()
No private properties found
N/A

Properties

$previous_data

$previous_data : null

Data that we will set before the update profile to compare it after update

Type

normal

$usermeta

$usermeta : null

Type

normal

$data

$data : null

Type

normal

$profile

$profile : null

Type

normal

$cannot_edit

$cannot_edit : null

Type

normal

$deleted_user_id

$deleted_user_id : null

Type

normal

$banned_keys

$banned_keys : array|string[]

Type

normal

$preview

$preview : bool

Type

normal

$send_mail_on_delete

$send_mail_on_delete : bool

Type

normal

$update_user_keys

$update_user_keys : array|string[]

A list of keys that should never be in wp_usermeta.

Type

normal

$target_id

$target_id : null

Type

normal

$updating_process

$updating_process

$cached_user

$cached_user : array

Type

normal

Methods

__construct()

__construct() : mixed

User constructor.

Returns

mixed

is_metakey_banned()

is_metakey_banned(string  $meta_key, mixed  $context = '') : bool

It validates the meta_key for wp_usermeta table.

Avoid to handle meta_key by the UM Forms if it contains $this->banned_keys inside.

Parameters

string $meta_key

Usermeta key.

mixed $context

Returns

bool

avoid_banned_keys()

avoid_banned_keys(null|bool  $check, int  $object_id, string  $meta_key) : null|bool

Low-level checking to avoid updating banned user metakeys while UM Forms submission.

Parameters

null|bool $check

Whether to allow updating metadata for the given type.

int $object_id

ID of the object metadata is for.

string $meta_key

Metadata key.

Returns

null|bool

flush_um_count_users_transient_update()

flush_um_count_users_transient_update( $meta_ids,  $object_id,  $meta_key,  $_meta_value) : mixed

Parameters

$meta_ids
$object_id
$meta_key
$_meta_value

Returns

mixed

flush_um_count_users_transient_add()

flush_um_count_users_transient_add( $meta_ids,  $object_id,  $meta_key,  $_meta_value) : mixed

Parameters

$meta_ids
$object_id
$meta_key
$_meta_value

Returns

mixed

flush_um_count_users_transient_delete()

flush_um_count_users_transient_delete( $meta_ids,  $object_id,  $meta_key,  $_meta_value) : mixed

Parameters

$meta_ids
$object_id
$meta_key
$_meta_value

Returns

mixed

on_delete_usermeta()

on_delete_usermeta(int|array  $meta_ids, int  $object_id, string  $meta_key, mixed  $_meta_value) : mixed

When you delete usermeta connected with member directory - reset it to default value

Parameters

int|array $meta_ids
int $object_id
string $meta_key
mixed $_meta_value

Returns

mixed

on_update_usermeta()

on_update_usermeta(int  $meta_id, int  $object_id, string  $meta_key, mixed  $_meta_value) : mixed

When you add/update usermeta connected with member directories - set this data to member directory metakey

Parameters

int $meta_id
int $object_id
string $meta_key
mixed $_meta_value

Returns

mixed

delete_user_handler()

delete_user_handler( $user_id) : mixed

Parameters

$user_id

Returns

mixed

check_membership()

check_membership() : mixed

Returns

mixed

add_um_role_existing_user()

add_um_role_existing_user( $user_id,  $result) : mixed

Multisite add existing user

Parameters

$user_id
$result

Returns

mixed

add_um_role_wpmu_new_user()

add_um_role_wpmu_new_user( $user_id) : mixed

Multisite add existing user

Parameters

$user_id

Returns

mixed

get_profile_slug()

get_profile_slug(int  $user_id, bool  $raw = false) : bool|mixed

Parameters

int $user_id
bool $raw

Returns

bool|mixed

get_profile_link()

get_profile_link( $user_id) : bool|string

Parameters

$user_id

Returns

bool|string

generate_user_hash()

generate_user_hash(mixed  $user_id) : mixed

Parameters

mixed $user_id

Returns

mixed

generate_profile_slug()

generate_profile_slug(int  $user_id, bool  $force = false) : mixed

Generate User Profile Slug and save to meta

Parameters

int $user_id
bool $force

Returns

mixed

user_register_via_admin()

user_register_via_admin( $user_id) : mixed

Backend user creation

Parameters

$user_id

Returns

mixed

profile_update()

profile_update(int  $user_id, \WP_User  $old_data) : mixed

On wp_update_user function complete

Parameters

int $user_id
\WP_User $old_data

Returns

mixed

profile_form_additional_section()

profile_form_additional_section(\WP_User  $userdata) : void

Additional section for WP Profile page with UM data fields

Parameters

\WP_User $userdata

User data

secondary_role_field()

secondary_role_field(string  $content, \WP_User  $userdata) : string

Default interface for setting a ultimatemember role

Parameters

string $content

Section HTML

\WP_User $userdata

User data

Returns

string

toArray()

toArray( $obj) : array

Converts object to array

Parameters

$obj

Returns

array

get_cached_data()

get_cached_data( $user_id) : mixed|string

Parameters

$user_id

Returns

mixed|string

setup_cache()

setup_cache( $user_id,  $profile) : mixed

Parameters

$user_id
$profile

Returns

mixed

remove_cache()

remove_cache( $user_id) : mixed

Parameters

$user_id

Returns

mixed

remove_cache_all_users()

remove_cache_all_users() : mixed

Remove cache for all users

Returns

mixed

set()

set(null|int  $user_id = null, bool  $clean = false) : mixed

This method lets you set a user. For example, to retrieve a profile or anything related to that user.

Parameters

null|int $user_id

Which user to retrieve. A numeric user ID

bool $clean

Should be true or false. Basically, if you did not provide a user ID It will set the current logged in user as a profile

Returns

mixed

Examples

The following example makes you set a user and retrieve their display name after that using the user API. <?php UM()->user()->set( 12 ); $display_name = UM()->user()->profile['display_name']; // Should print user display name ?>

                                                

reset()

reset(bool  $clean = false) : mixed

Reset user data

Parameters

bool $clean

Returns

mixed

auto_login()

auto_login(int  $user_id, int|bool  $rememberme) : mixed

This method lets you auto sign-in a user to your site.

Parameters

int $user_id

Which user ID to sign in automatically

int|bool $rememberme

Should be true or false. If you want the user sign in session to use cookies, use true

Returns

mixed

Examples

The following example lets you sign in a user automatically by their ID. <?php UM()->user()->auto_login( 2 ); ?>

                                            
The following example lets you sign in a user automatically by their ID and makes the plugin remember their session. <?php UM()->user()->auto_login( 10, true ); ?>

                                                

set_registration_details()

set_registration_details(array  $submitted, array  $args, array  $form_data) : mixed

Set user's registration details

Parameters

array $submitted
array $args
array $form_data

Returns

mixed

set_last_login()

set_last_login() : mixed

Set last login for new registered users

Returns

mixed

set_status()

set_status( $status) : mixed

Set user's account status

Parameters

$status

Returns

mixed

assign_secretkey()

assign_secretkey() : mixed

Set user's hash

Returns

mixed

maybe_generate_password_reset_key()

maybe_generate_password_reset_key(\WP_User  $userdata) : string|\WP_Error

Parameters

\WP_User $userdata

Returns

string|\WP_Error

password_reset()

password_reset() : mixed

Password reset email

Returns

mixed

password_changed()

password_changed(null|int  $user_id = null) : mixed

Password changed email

Parameters

null|int $user_id

Returns

mixed

approve()

approve(mixed  $repeat = true) : mixed

This method approves a user membership and sends them an optional welcome/approval email.

Parameters

mixed $repeat

Returns

mixed

Examples

Approve a pending user and allow him to sign-in to your site. <?php um_fetch_user( 352 ); UM()->user()->approve(); ?>

                                                

email_pending()

email_pending() : mixed

Pending email

Returns

mixed

pending()

pending() : mixed

This method puts a user under manual review by administrator and sends them an optional email.

Returns

mixed

Examples

An example of putting a user pending manual review <?php um_fetch_user( 54 ); UM()->user()->pending(); ?>

                                                

reject()

reject() : mixed

This method rejects a user membership and sends them an optional email.

Returns

mixed

Examples

Reject a user membership example <?php um_fetch_user( 114 ); UM()->user()->reject(); ?>

                                                

deactivate()

deactivate() : mixed

This method deactivates a user membership and sends them an optional email.

Returns

mixed

Examples

Deactivate a user membership with the following example <?php um_fetch_user( 32 ); $ultimatemember->user->deactivate(); ?>

                                                

delete()

delete(bool  $send_mail = true) : mixed

Delete user

Parameters

bool $send_mail

Returns

mixed

get_role()

get_role() : string

This method gets a user role in slug format. e.g. member

Returns

string

Examples

Do something if the user's role is paid-member <?php um_fetch_user( 12 ); if ( UM()->user()->get_role() == 'paid-member' ) { // Show this to paid customers } else { // You are a free member } ?>

                                                

update_usermeta_info()

update_usermeta_info( $key) : mixed

Update one key in user meta

Parameters

$key

Returns

mixed

delete_meta()

delete_meta(string  $key) : mixed

This method can be used to delete user's meta key.

Parameters

string $key

The meta field key to remove from user

@example Delete user's age field

<?php

um_fetch_user( 15 ); UM()->user()->delete_meta( 'age' );

?>

Returns

mixed

get_admin_actions()

get_admin_actions() : array|bool

Get admin actions for individual user

Returns

array|bool

is_profile_noindex()

is_profile_noindex(int  $user_id) : bool

This method checks if the profile indexing is disabled

Parameters

int $user_id

Returns

bool —

Is the profile indexing disabled?

is_private_profile()

is_private_profile(int  $user_id) : bool

This method checks if give user profile is private.

Parameters

int $user_id

A user ID must be passed to check if the user profile is private

Returns

bool

Examples

This example display a specific user's name If his profile is public <?php um_fetch_user( 60 ); $is_private = UM()->user()->is_private_profile( 60 ); if ( ! $is_private ) { echo 'User is public and his name is ' . um_user('display_name'); } ?>

                                                

is_approved()

is_approved(int  $user_id) : bool

This method can be used to determine If a certain user is approved or not.

Parameters

int $user_id

The user ID to check approval status for

Returns

bool

Examples

Do something If a user's membership is approved <?php if ( UM()->user()->is_approved( 55 ) { // User account is approved } else { // User account is not approved } ?>

                                                

is_private_case()

is_private_case( $user_id,  $case) : bool

Is private

Parameters

$user_id
$case

Returns

bool

update_files()

update_files( $changes) : mixed

Update files

Parameters

$changes

Returns

mixed

update_profile()

update_profile(array  $changes, string  $context = '') : mixed

Update profile

Parameters

array $changes
string $context

Returns

mixed

user_has_metadata()

user_has_metadata( $key,  $value) : bool|int

User exists by meta key and value

Parameters

$key
$value

Returns

bool|int

user_exists_by_name()

user_exists_by_name( $value) : bool

User exists by name

Parameters

$value

Returns

bool

user_exists_by_id()

user_exists_by_id(int  $user_id) : bool|int

This method checks if a user exists or not in your site based on the user ID.

Parameters

int $user_id

A user ID must be passed to check if the user exists

Returns

bool|int

Examples

Basic Usage <?php $boolean = UM()->user()->user_exists_by_id( 15 ); if ( $boolean ) { // That user exists } ?>

                                                

user_exists_by_hash()

user_exists_by_hash(string  $hash) : bool|int

Parameters

string $hash

Returns

bool|int

user_exists_by_custom_meta()

user_exists_by_custom_meta(string  $slug) : bool|int

Parameters

string $slug

Returns

bool|int

user_exists_by_email_as_username()

user_exists_by_email_as_username(string  $slug) : bool

This method checks if a user exists or not in your site based on the user email as username

Parameters

string $slug

A user slug must be passed to check if the user exists

Returns

bool

Examples

Basic Usage <?php $boolean = UM()->user()->user_exists_by_email_as_username( 'calumgmail-com' ); if ( $boolean ) { // That user exists } ?>

                                                

set_gravatar()

set_gravatar( $user_id) : string

Set gravatar hash id

Parameters

$user_id

Returns

string

add_activation_placeholder()

add_activation_placeholder( $placeholders) : array

UM Placeholders for activation link in email

Parameters

$placeholders

Returns

array

add_activation_replace_placeholder()

add_activation_replace_placeholder( $replace_placeholders) : array

UM Replace Placeholders for activation link in email

Parameters

$replace_placeholders

Returns

array

get_pending_users_count()

get_pending_users_count() : mixed

Get pending users (in queue)

Returns

mixed

remove_cached_queue()

remove_cached_queue() : mixed

Remove cached queue from Users backend

Returns

mixed

clean()

clean() : mixed

Clean user profile before set.

Returns

mixed