Check if “Send the new user an email about their account” is ticked

I believe I found a solution. Not sure if it is the best solution but at least it serves the purpose:

if ( !function_exists('wp_new_user_notification') ) {
  function wp_new_user_notification( $user_id, $plaintext_pass="" ) {

    if($_POST['action'] == 'createuser'){

      if($_POST['send_user_notification'] == 1){

        $user = new WP_User($user_id);
        $plaintext_pass = $_POST['pass1'];
        wp_set_password( $plaintext_pass, $user_id );

        $user_login = stripslashes($user->user_login);
        $user_email = stripslashes($user->user_email);

        if ( empty($plaintext_pass) )
        return;

        if($_POST['activate_user'] == 1){
          $headers = "From: xxxxxx <[email protected]>\r\n";
          $subject = "Thank you for registering for ".get_option('blogname')."";
          $message = "Thank you for registering here are your log in details keep them safe, your account is now active\n\n";
          $message .= "username: ".$user_login."\n";
          $message .= "password:  ".$plaintext_pass."\n\n";
          $message .= "Click here to log in:\n";
          $message .= site_url( "https://wordpress.stackexchange.com/")."\n\n";
          $message .= "----------------------------------\n";
          $message .= "This is an automated message from ".get_option('blogname')."\n";
          $message .= "Please do not reply to this address\n";

          wp_mail($user_email, $subject, $message, $headers);

        }else{

          $headers = "From: xxxxxx <[email protected]>\r\n";
          $subject = "Thank you for registering for ".get_option('blogname')."";
          $message = "Thank you for registering here are your log in details keep them safe, your account is pending so we will be in touch shortly\n\n";
          $message .= "username: ".$user_login."\n";
          $message .= "password:  ".$plaintext_pass."\n\n";
          $message .= "----------------------------------\n";
          $message .= "This is an automated message from ".get_option('blogname')."\n";
          $message .= "Please do not reply to this address\n";

          wp_mail($user_email, $subject, $message, $headers);

        }

      }

    }
  }
}