• Resolved sophierose

    (@sophierose)


    Hello,

    Your plugin is working almost as expected, however there are a few issues:

    1. Can you tell me where the plugin is getting the admin emails from to send the notifications? I obviously only have one wordpress admin email, but the notification email is being sent to three email addresses, all of which are related emails to ones I’ve used as admin emails in the past, but no longer use 2 of them. I’ve looked for these emails in settings somewhere but cannot find them anywhere?!

    https://tinyurl.com/ye3gcutd

    2. The notification shown on your screenshots for the account activation is not being shown on my site?

    https://www.sypac.co.uk/register/

    Let me know if you need anything else.

    Huge thanks!

    The page I need help with: [log in to see the link]

Viewing 15 replies - 16 through 30 (of 34 total)
  • Would also be great if we could just define which role receives email notifications; with the aid of the user role editor plugin we could just create a role that is specific to BP user administration. I attempted the line $new_admins[] = get_users( 'role=portal_admin' ); but this did nothing.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    @elizoliva

    Looking over my previous code example from *checks* 10 months ago…wasn’t quite right. I realize me saying and demo’ing just inserting an email address as part of the indexes is actually wrong, as both spots where we use this filter is going to pass in an array of WP_User objects, and extract out the details it needs afterwards.

    So, let’s have you try this version:

    function elizoliva_bpro_single_admin_notice( $default_admins ) {
    	// BuddyPress Registration Options will be expecting an array.
    	$new_admins = array();
    	$portal_admins = get_users( 'role=portal_admin' );
    
    	foreach( $portal_admins as $portal_admin ) {
    		$new_admins[] = $portal_admin;
    	}
    
    	return $new_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'elizoliva_bpro_single_admin_notice' );
    

    I believe this should handle just setting up your portal_admin users to receive the notifications, instead of the default administrators.

    Give it a try and let me know how that goes.

    Yes I was looking at the function in the plugin against what I had in my custom plugin and figured there was definitely something amiss.

    This worked perfectly, thank you so much! And thank you for such a prompt reply, my client will be pleased!

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome. Meanwhile I feel silly for miss-interpreting my own code! Talk about a face colored derple ??

    I know this was resolved, but I wanted to try and add “2” admin emails to the notifications, instead of the SINGLE one that you made a snippet for. Is there an array we could use for “email1, email2”?

    Can you share the snippet please? Thanks!

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    @eberswine

    the snippet above is handling 1 to many email addresses, depending on how many portal_admin users the previous person had in the site.

    That said, at least for a hardcoded list version, something like this would get you 3 fake addresses added, that you could amend and fill in yourself and repeat as necessary.

    function eberswine_bpro_single_admin_notice( $default_admins ) {
    	// BuddyPress Registration Options will be expecting an array.
    	$new_admins = array();
    	
    	$new_admins[] = '[email protected]';
    	$new_admins[] = '[email protected]';
    	$new_admins[] = '[email protected]';
    
    	return $new_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'eberswine_bpro_single_admin_notice' );
    

    so good! Thank you!!

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

    Following up on this thread. I am attempting to use the snipped above to manually add several email addresses to send the New Member Approval emails to. I have copy/pasted the snippet above for eberswine and replaced the email addresses with my own, however the emails are not being sent when creating new users. When I remove the above snippet, all admins are sent the email when a new user is created.

    Below is my custom functions in my functions.php file.

    /****************************** CUSTOM FUNCTIONS ******************************/
    
    // Add your own custom functions here
    
    function bb_remove_password_strength() {
    	if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
    		wp_dequeue_script( 'wc-password-strength-meter' );
    	}
    }
    //add_action( 'wp_print_scripts', 'bb_remove_password_strength', 100 );
    
    function custom_remove_password_strength() {
    if ( wp_script_is( 'bp-nouveau-password-verify', 'enqueued' ) ) {
        wp_dequeue_script( 'bp-nouveau-password-verify' );
      }
    } 
    add_action( 'wp_print_scripts', 'custom_remove_password_strength', 100 );
    
    function year_shortcode() {
      $year = date('Y');
      return $year;
    }
    add_shortcode('year', 'year_shortcode');
    
    function eberswine_bpro_single_admin_notice( $default_admins ) {
    	// BuddyPress Registration Options will be expecting an array.
    	$new_admins = array();
    	
    	$new_admins[] = '[email protected]';
    	$new_admins[] = '[email protected]';
    	$new_admins[] = '[email protected]';
    
    	return $new_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'eberswine_bpro_single_admin_notice' );
    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi @codemodeio

    I think in a different thread somewhere, or maybe some private support, I realized my code above is not accurate, and we’re expecting WP_User objects, not just straight up emails. Because of that, I have amended sample code to be more accurate. Please try the version below, with the email addresses swapped out with the intended ones.

    function codemodeio_bpro_single_admin_notice( $default_admins ) {
    
    	// BuddyPress Registration Options will be expecting an array.
    	$new_admins = array();
    
    	foreach(
    		array(
    			'[email protected]',
    			'[email protected]',
    			'[email protected]'
    		) as
    		$user_email
    	) {
    		$user = get_user_by( 'email', $user_email );
    		if ( false !== $user ) {
    			$new_admins[] = $user;
    		}
    	}
    
    	if ( ! empty( $new_admins ) ) {
    		return $new_admins
    	}
    
    	return $default_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'codemodeio_bpro_single_admin_notice' );
    

    Let me know if you have any questions about what the code is doing, I can answer for you.

    This is still not working as intended. I’ve replaced the email addresses, but it is still sending emails to the main site admin (which is not listed), then the first email address in that list, but none of the others.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure if affecting things on your end, but i realized i missed a semicolon on the line that has this:

    return $new_admins
    

    Testing out on my end quick.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    @codemodeio can you provide me a dummy-fied version of the emails you’re seeing?

    For example, if you have [email protected] as the admin email setting, then also [email protected], [email protected] etc, and then which ones would actually get the emails?

    Asking because I’m seeing in the bp_registration_options_send_admin_email() function which handles the emailing of admins, and the “New Member Request” email, we’re grabbing the admin_email setting, and then merging in the ones provided by the filter above, and then reducing it down to just unique values. Just the unique ones will get sent anything.

    The missing ; was not the issue. This is the email I am receiving:

    [email protected] ( [email protected] ) would like to become a member of your website. To accept or reject their request, please go to Member Requests

    I have one admin email that I am trying to send these emails to. That email is the admin email of the site. The plugin is currently sending emails to every admin of the site.

    When I add the code above, using 3 real emails instead of “[email protected]” I am getting very strange behavior. If I enter the desired admin email, followed by 2 real email addresses, every admin gets the email. If I leave out the desired email address and replace with 3 real email addresses, I get the email sent only to the desired email (which was excluded) and the first email in the list of the code. The other 2 emails in the code do not receive the email.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Forgot to mention in my last reply that we’re also doing existing WP user checks as part of that merging and filtering. It’s not going to send to some arbitrary email address provided, and I feel I did not clarify that accurately in my most recent replies and the past with other threads.

    So perhaps to help confirm, all the emails you’re intending for this have a user in the install? Doesn’t need to necessarily be an administrator user, from what I’m seeing in our code. Just needs to have the user.

Viewing 15 replies - 16 through 30 (of 34 total)
  • The topic ‘Admin Email Notifications’ is closed to new replies.