• Resolved bcunningham

    (@bcunningham2gmailcom)


    Some of the emails through the registration/moderation/approval process come through the “BP Registration Options” screen, and some through the Buddypress Email section.

    Is there a setting, or a snippet that can be applied that could do either of the following:

    • Send a selected email from the Buddypress Email section (they can be customized in format and style, also in html vs just text emails)?
    • or Change the Subject of the Email, to also include the site name?

    Many Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    For what it’s worth, we don’t overtake the default email notifications for a BuddyPress user registration, we add a small handful of extra ones, which is why there’s the different sources you mention above.

    We don’t have BuddyPress Email integration with that UI at the moment, but I know I want to switch over to that eventually. Haven’t managed to find the time thus far.

    Are you wanting to potentially customize the “New Member Request” text itself?

    Thread Starter bcunningham

    (@bcunningham2gmailcom)

    I’d be happy if at least the Subject for the Pending Membership and Membership Approved emails.

    If they could say “[Sitename] Pending Membership” or “[Sitename] Membership Approved”, then they would at least match the others being sent out by the BP mail system.

    I don’t know if that would benefit anyone else, though. That’s why I was wondering if it could be handled with a snippet.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    The membership approved messaging is going to be the easier of the two in the current state, if you know how to handle some WordPress filters and whatnot. Below is a snippet from the codebase that sends out the “Approved/Denied” messaging

    /**
     * Filters the email arguments before mailing.
     *
     * @since 4.2.0
     *
     * @param array  $emailme Array of email arguments for wp_mail.
     * @param object $user User object for user being moderated.
     */
    $mailme_filtered = apply_filters( 'bpro_hook_before_email', $mailme, $user );
    wp_mail( $mailme_filtered['user_email'], $mailme_filtered['user_subject'], $mailme_filtered['user_message'] );
    

    You could use the `bpro_hook_before_email filter to change the subject.

    function support_change_subject( $mail_parts, $user ) {
    	$mail_parts['user_subject'] = 'WELCOME TO THE PARTAY!!!';
    
    	return $mail_parts;
    }
    add_filter( 'bpro_hook_before_email', 'support_change_subject', 10, 2 );
    

    Same filter is also useful if you somehow have need to change the destination email and the message itself, but no one has ever had need for that thus far that I’ve seen.

    The Pending Membership subject is the difficult one because I don’t have any filters handily in place, so you could probably get to it deep within the wp_mail function, or via a gettext filter. I can type an example of at least the gettext version pretty quick if it’s of interest to you that much.

    Thread Starter bcunningham

    (@bcunningham2gmailcom)

    Your snippet works, and if it’s too difficult to change the pending subject, I’ll just live with it.

    Separate question… when I use your plugin to approve a registration, it doesn’t appear to apply a site role or a forum role. The setting in WP > Settings > General for “New User Default Role” is set to “Subscriber”, but for some reason this doesn’t get applied, and I’m having to go in manually and set that. The “participant” forum role seems like it’s applied when the user logs in for the first time? But that’s not entirely clear either, as some who’ve registered have the role, and others don’t. Any ideas?

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not so much that it’s insanely difficult, it’s just that it’s an extremely commonly applied filter.

    function bpro_support_pending_membership_text( $current, $original ) {
    	if ( $original !== 'Pending Membership' ) {
    		return $current;
    	}	
    	return 'Yo, pending membership to approve!';
    }
    add_filter( 'gettext', 'bpro_support_pending_membership_text', 10, 2 )
    

    All of the roles and capabilities and whatnot should already be getting applied, as we don’t interfere/interject with those processes. Essentially once a user has activated, we just attach some user meta to their account, and we check that to determine if they should be allowed to places. So, I can’t say for certain what may be going on with that.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change Subject?’ is closed to new replies.