S
S
S1MY2020-04-20 13:23:23
WordPress
S1MY, 2020-04-20 13:23:23

How to add an ending to the registration date of a wordpress user?

Good day, it became necessary to add a registration end date for users.
And I need advice, since I'm facing this for the first time.
User registration takes place through the admin panel and for a user of a certain role, you must specify the expiration date of his account, and upon expiration, the account must be deleted.
What is the best way to write this?
I know that there is a plugin that creates temporary accounts, but for this purpose it is not suitable.
Thanks in advance for your help, much appreciated!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2020-04-20
@wppanda5

When registering, you add to the user in the 'hex_date' field the timestamp of the expiration of the account.
Delete - so

$hex_time = get_user_meta($user_id, 'hex_date',true);
if( time() > $hex_time ) {
wp_delete_user( $user_id );
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question