Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // SET BP to use WP_MAIL
- add_filter( 'bp_email_use_wp_mail', '__return_true' );
- // Set messages to HTML for BP sent emails.
- add_filter( 'wp_mail_content_type', function( $default ) {
- if ( did_action( 'bp_send_email' ) ) {
- return 'text/html';
- }
- return $default;
- } );
- // Use HTML template
- add_filter(
- 'bp_email_get_content_plaintext',
- function( $content, $property, $transform, $bp_email ) {
- if ( ! did_action( 'bp_send_email' ) ) {
- return $content;
- }
- return $bp_email->get_template( 'add-content' );
- },
- 10,
- 4
- );
- //NOTIFY USER when their Role has Been Changed to Member
- // (A) FUNCTION
- function user_role_update( $user_id, $new_role ) {
- if ($new_role == 'Member') {
- $site_url = get_bloginfo('wpurl');
- $user_info = get_userdata( $user_id );
- // (B) MAIL SETTINGS
- $to = $user_info->user_email;
- $setFrom('members@site.com') ;
- // (C) SET IMAGE
- $img = "local/Logo-72-1.webp";
- // (D) SET SUBJECT LINE
- $subject = "Role changed: ".$site_url."";
- // (E) MAIL MESSAGE
- $message = "Welcome " . $user_info->display_name. " you have been added as a ". $new_role." on site.com. Congratulations you can now access the members' area, make posts, and make online camp bookings on the Camp Page. You can access the site here: ".$site_url."";
- $message = "$AddEmbeddedImage('$img')";
- "";
- //$message .= "<a href='$img' rel="nofollow ugc">Can't see the image? Click Here.</a>";
- // (F) SEND
- wp_mail($to, $subject, $message, $mailHead);
- }
- }
- add_action( 'set_user_role', 'user_role_update', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement