Installer
3 years ago
AdminNotices.php
2 months ago
AjaxHandler.php
1 year ago
Autologin.php
9 months ago
BlockRegistrations.php
10 months ago
BuddyPressBbPress.php
3 years ago
DisableConcurrentLogins.php
2 years ago
EditUserProfile.php
5 months ago
ExtensionManager.php
1 month ago
FileUploader.php
3 months ago
FormPreviewHandler.php
5 months ago
FormRepository.php
1 year ago
FormShortcodeDefaults.php
1 month ago
GDPR.php
3 years ago
Geolocation.php
3 years ago
GlobalSiteAccess.php
3 years ago
ImageUploader.php
1 year ago
LoginAuth.php
1 year ago
Miscellaneous.php
3 years ago
ModifyRedirectDefaultLinks.php
4 hours ago
PPRESS_Session.php
1 year ago
PROFILEPRESS_sql.php
1 year ago
PasswordReset.php
1 year ago
ProfileUrlRewrite.php
4 years ago
RegistrationAuth.php
1 week ago
SendEmail.php
3 years ago
ShortcodeThemeFactory.php
5 years ago
UserAvatar.php
1 year ago
UserSignupLocationListingPage.php
3 years ago
UsernameEmailRestrictLogin.php
4 years ago
WPProfileFieldParserTrait.php
1 year ago
WelcomeEmailAfterSignup.php
1 year ago
default-email-template.php
1 year ago
index.php
3 years ago
WelcomeEmailAfterSignup.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Classes; |
| 4 | |
| 5 | class WelcomeEmailAfterSignup |
| 6 | { |
| 7 | private $wp_user; |
| 8 | |
| 9 | private $password; |
| 10 | |
| 11 | public function __construct($user_id, $password) |
| 12 | { |
| 13 | $this->wp_user = get_userdata($user_id); |
| 14 | $this->password = $password; |
| 15 | |
| 16 | $this->send_welcome_mail(); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Format the email message and replace placeholders with real values |
| 21 | */ |
| 22 | public function parse_placeholders($content) |
| 23 | { |
| 24 | $search = apply_filters('ppress_welcome_message_placeholder_search', [ |
| 25 | '{{username}}', |
| 26 | '{{userid}}', |
| 27 | '{{password}}', |
| 28 | '{{email}}', |
| 29 | '{{site_title}}', |
| 30 | '{{first_name}}', |
| 31 | '{{last_name}}', |
| 32 | '{{password_reset_link}}', |
| 33 | '{{login_link}}' |
| 34 | ]); |
| 35 | |
| 36 | $replace = apply_filters('ppress_welcome_message_placeholder_replace', [ |
| 37 | $this->wp_user->user_login, |
| 38 | $this->wp_user->ID, |
| 39 | empty($this->password) ? esc_html__('[Your Password]', 'wp-user-avatar') : $this->password, |
| 40 | $this->wp_user->user_email, |
| 41 | ppress_site_title(), |
| 42 | $this->wp_user->first_name, |
| 43 | $this->wp_user->last_name, |
| 44 | ppress_generate_password_reset_url($this->wp_user->user_login), |
| 45 | ppress_login_url() |
| 46 | ]); |
| 47 | |
| 48 | return ppress_custom_profile_field_search_replace( |
| 49 | str_replace($search, $replace, $content), |
| 50 | $this->wp_user |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | public function send_welcome_mail() |
| 55 | { |
| 56 | $subject = ppress_get_setting('welcome_message_email_subject', sprintf(esc_html__('Welcome To %s', 'wp-user-avatar'), ppress_site_title()), true); |
| 57 | $subject = $this->parse_placeholders($subject); |
| 58 | |
| 59 | $message = apply_filters( |
| 60 | 'ppress_welcome_message_raw_content', |
| 61 | ppress_get_setting('welcome_message_email_content', ppress_welcome_msg_content_default(), true), |
| 62 | $this->wp_user, |
| 63 | $this->password |
| 64 | ); |
| 65 | |
| 66 | $message = $this->parse_placeholders($message); |
| 67 | |
| 68 | ppress_send_email($this->wp_user->user_email, $subject, $message); |
| 69 | } |
| 70 | } |
| 71 |