Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. // SET BP to use WP_MAIL
  4. add_filter( 'bp_email_use_wp_mail', '__return_true' );
  5.  
  6. // Set messages to HTML for BP sent emails.
  7. add_filter( 'wp_mail_content_type', function( $default ) {
  8.     if ( did_action( 'bp_send_email' ) ) {
  9.         return 'text/html';
  10.     }
  11.     return $default;
  12. } );
  13.  
  14. // Use HTML template
  15. add_filter(
  16.     'bp_email_get_content_plaintext',
  17.     function( $content, $property, $transform, $bp_email ) {
  18.         if ( ! did_action( 'bp_send_email' ) ) {
  19.             return $content;
  20.         }
  21.         return $bp_email-&gt;get_template( 'add-content' );
  22.     },
  23.     10,
  24.     4
  25. );
  26.  
  27. //NOTIFY USER when their Role has Been Changed to Member
  28.  
  29. // (A) FUNCTION
  30. function user_role_update( $user_id, $new_role ) {
  31.     if ($new_role == 'Member') {
  32.         $site_url = get_bloginfo('wpurl');
  33.         $user_info = get_userdata( $user_id );
  34.      
  35. // (B) MAIL SETTINGS
  36.         $to = $user_info-&gt;user_email;
  37.         $setFrom('members@site.com') ;
  38.  
  39. // (C) SET IMAGE
  40.         $img = "local/Logo-72-1.webp";
  41.        
  42.  
  43. // (D) SET SUBJECT LINE
  44.        $subject = "Role changed: ".$site_url."";
  45.        
  46. // (E) MAIL MESSAGE
  47.         $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."";
  48.         $message = "$AddEmbeddedImage('$img')";
  49.         "";
  50.         //$message .= "<a href='$img' rel="nofollow ugc">Can't see the image? Click Here.</a>";
  51. // (F) SEND
  52.         wp_mail($to, $subject, $message, $mailHead);
  53.     }
  54. }
  55. add_action( 'set_user_role', 'user_role_update', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement