user_email ) { return false; } $subject = sprintf( /* translators: %s: site name */ __( 'Confirm your email for %s', 'unsupervised-schedular' ), $this->siteName() ); $body = sprintf( /* translators: 1: site name, 2: confirmation URL */ __( "Thanks for signing up at %1\$s.\n\nPlease confirm your email address by opening this link:\n%2\$s\n\nOnce confirmed, a studio admin will review and approve your account. You'll get another email when it's ready.", 'unsupervised-schedular' ), $this->siteName(), $confirmUrl ); return (bool) wp_mail( $user->user_email, $subject, $body ); } /** * Tell the studio admins a self-signup has confirmed their email and is * waiting for approval. Sent to the site admin email. */ public function notifyAdminsPending( \WP_User $user ): bool { $adminEmail = Val::string( get_option( 'admin_email', '' ) ); if ( '' === $adminEmail ) { return false; } $subject = __( 'A new student is awaiting approval', 'unsupervised-schedular' ); $body = sprintf( /* translators: 1: student name, 2: student email */ __( "%1\$s (%2\$s) has confirmed their email and is awaiting approval.\n\nReview them under Students → Pending Students in wp-admin.", 'unsupervised-schedular' ), (string) $user->display_name, (string) $user->user_email ); return (bool) wp_mail( $adminEmail, $subject, $body ); } /** * Tell the student their account has been approved. Returns false when there * is no recipient. */ public function sendApproved( \WP_User $user ): bool { if ( '' === (string) $user->user_email ) { return false; } $subject = sprintf( /* translators: %s: site name */ __( 'Your %s account is approved', 'unsupervised-schedular' ), $this->siteName() ); $body = sprintf( /* translators: 1: site name, 2: login URL */ __( "Good news — your account at %1\$s has been approved. You can now log in and book:\n%2\$s", 'unsupervised-schedular' ), $this->siteName(), wp_login_url() ); return (bool) wp_mail( $user->user_email, $subject, $body ); } /** * Tell an applicant their registration was declined. Takes the email address * directly, since the account is deleted as part of rejection. */ public function sendRejected( string $email ): bool { if ( '' === $email ) { return false; } $subject = sprintf( /* translators: %s: site name */ __( 'Your %s registration', 'unsupervised-schedular' ), $this->siteName() ); $body = sprintf( /* translators: %s: site name */ __( 'Thank you for your interest in %s. We are unable to approve your registration at this time. Please contact the studio if you have any questions.', 'unsupervised-schedular' ), $this->siteName() ); return (bool) wp_mail( $email, $subject, $body ); } /** * Tell a registered student they have been given access to an invite-only * group class and can now enrol. Returns false when there is no recipient. */ public function sendClassAccessGranted( \WP_User $user, string $className ): bool { if ( '' === (string) $user->user_email ) { return false; } $subject = sprintf( /* translators: %s: class title */ __( 'You have been invited to %s', 'unsupervised-schedular' ), $className ); $body = sprintf( /* translators: 1: class title, 2: site name, 3: login URL */ __( "You have been given access to the group class \"%1\$s\" at %2\$s.\n\nLog in and open the group classes page to enrol:\n%3\$s", 'unsupervised-schedular' ), $className, $this->siteName(), wp_login_url() ); return (bool) wp_mail( $user->user_email, $subject, $body ); } /** * Email a tokenised registration link to someone invited to a group class who * does not yet have an account. Returns false when there is no recipient. */ public function sendClassInvite( string $email, string $link, string $className ): bool { if ( '' === $email ) { return false; } $subject = sprintf( /* translators: %s: class title */ __( 'You are invited to join %s', 'unsupervised-schedular' ), $className ); $body = sprintf( /* translators: 1: class title, 2: site name, 3: registration URL */ __( "You have been invited to the group class \"%1\$s\" at %2\$s.\n\nCreate your account using this link, then choose to enrol in the class:\n%3\$s", 'unsupervised-schedular' ), $className, $this->siteName(), $link ); return (bool) wp_mail( $email, $subject, $body ); } private function siteName(): string { $name = (string) get_bloginfo( 'name' ); return '' !== $name ? $name : __( 'the studio', 'unsupervised-schedular' ); } }