• Resolved freedom667

    (@freedom667)


    I have a function but I don’t know how will I execute it. This function controls entered date and compares with today. if expire, the function delete the level

    add_action( 'user_profile_update_errors', 'crf_user_profile_update_errors', 10, 3 );
    function crf_user_profile_update_errors($errors, $update, $user ) {
    	$current_date = date("Y-m-d");
    	$date_to_compare = $_POST['year_of_birth'];
    	if ( ! $update ) {
    		return;
    	}
    				//Bugünün Tarihi//          //Girilen Tarih//
    	if (strtotime($current_date) > strtotime($date_to_compare)) {
    		$user_levels = rua_get_user($user)->get_level_ids(false, false, true);
    		foreach ($user_levels as $level) {
    		        rua_get_user($user)->remove_level($level);
    		    }
    	}
    }

    this function just works with pressing “Edit Profile” button in User Edit page

    • This topic was modified 4 years, 3 months ago by freedom667.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘execute a function each day’ is closed to new replies.