For activation process you can follow following steps:
- As you can see
user_activation_key
column inwp_users
table. You can make use of that column for sending user activation link. -
While signing up users you can insert certain code into that column
with custom sql. After the user is signed up with
wp_insert_user()
and returns an id to$user_id
, a custom insert
sql can be run$user_id = wp_insert_user($user_detail); if ( $user_id && !is_wp_error( $user_id ) ) { $code = sha1( $user_id . time() ); global $wpdb; $wpdb->update( 'wp_users', //table name array( 'user_activation_key' => $code, // string ), array( 'ID' => $user_id ), array( '%s', // value1 ) ); $activation_link = add_query_arg( array( 'key' => $code, 'user' => $user_id ), get_permalink( /* your activation page id here*/ )); wp_mail( $user_email, 'SUBJECT', 'Activation link : ' . $activation_link ); }.
This will send user an activation link like
http://example.com/activation-page/?key=CERTAIN_KEY&user=USER_ID
to their email and on the activation page you can run code for activating the users by altering another columnuser_status
from 0 to 1. -
After this you can run for another update for
user_status
column byglobal $wpdb; $wpdb->update( 'wp_users', //table name array( 'user_status' => 1, // integer ), array( 'ID' => $_GET['user'], //where clause 'user_activation_key'=>$_GET['key'] //where clause ), array( '%d', //value1 ) );
Than you can allow users having status 1 to sign in.