• 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 - 1 through 15 (of 34 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi there,

    1. As is, we notify all the administrators, so we’re fetching that list of users with a role of “administrator” and iterate over each. In case you’ve opened up the plugin core.php file, it’s towards the top of the bp_registration_options_bp_core_register_account() function.

    If you want, I can provide a snippet of code to have it only email specific user(s).

    2. Which notification are you referring to? Screenshot 2 is only after a user has gone through the activation process, and Screenshot 3 is if you have a private network set and they’ve activated.

    I do want to make sure it’s known that we don’t prevent global access to the entirety of the site, just the BuddyPress/bbPress areas, depending on your settings. Private network restricts them to user profiles. Just having “must be moderated” gives them the ability to browse around and read, but we hide UI to the best of our ability to interact.

    Thread Starter sophierose

    (@sophierose)

    1. Ah I see! Yes that would be great, just the main wordpress admin email would be great.

    2. https://ps.w.org/bp-registration-options/assets/screenshot-2.png?rev=1680432
    I don’t get this one when testing the process, so when I’ve activated, it doesn’t show up with the message, but I get the one when logged into the site but not yet approved(screenshot 3).

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    1. Give this a try in your active theme’s functions.php or perhaps a custom plugin if you’re feeling fancy.

    function sophierose_bpro_single_admin_notice( $default_admins ) {
    	// BuddyPress Registration Options will be expecting an array.
    	$new_admins = array();
    
    	// So we will return an array with one item, the admin_email setting.
    	$new_admins[] = get_option( 'admin_email' );
    
    	return $new_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'sophierose_bpro_single_admin_notice' );
    

    2. That one is output on both the bp_after_activate_content and bp_before_member_header hooks. Not sure if you have a customized BP theme that may not be using them, or if we have some compatibility issues we need to check on. Any insight on any customization maybe done?

    If I were wanting to change this myself for my own site, which fields would I need to change in this code? I also want the email to be sent to only the main admin and not all admin rights having people on the site.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    @undercoverotter so, say you specifically, want to be the only one notified?

    For this line:

    $new_admins[] = get_option( 'admin_email' );
    

    Instead of doing the get_option() call, just add your own email specifically:

    $new_admins[] = '[email protected]';
    

    Awesome! Thank you for your superfast reply! (also. I now wish I did own ottersus)

    Thanks!

    I tried the snippet above, (see below) no joy… Am I missing something?

    I have a site with 5 admins and only want one admin to get the notice of new signup.
    Here is the snippet I’m using in my function.php file…

    /*** NTP ***
    * Send new signups notice to just one Admin
    */
    
    function ntp_bpro_single_admin_notice( $default_admins ) {
    // BuddyPress Registration Options will be expecting an array.
    ???$new_admins = array();
    
    // This will send to ALL admin. return an array with one item, the admin_email setting.
    ??? // $new_admins[] = get_option( 'admin_email' );
    
    // this will send to just one admin
       $new_admins[] = '[email protected]';
    
      return $new_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'ntp_bpro_single_admin_notice' );
    }

    I am getting the following error
    “There has been a critical error on your website.”
    Debug shows the following:
    “Parse error: syntax error, unexpected ‘$new_admins’ (T_VARIABLE)”

    Thanks

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    I wonder if you maybe accidentally pasted this inside a different function declaration. That } after the add_filter line is suspect. Perhaps try moving that trailing } to above the /*** NTP *** line

    Hi,

    this is a very interesting thread, thanks for all your ideas. What we are trying to solve is to send an email to a specific admin depending on a group. A user can choose from 1 group when signing up and we have 1 admin responsible for each group.

    Do you think there is anything we could tailor here?

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Probably not going to be that easy as there’s no really great way that I can think of to retrieve the chosen group during a point when you’d be filtering the email to send to.

    Maybe by checking the $_POST global but I don’t know what that index would potentially be.

    Hi Michael,

    thanks for your answer.

    We have a mandatory field with a dropdown select box for the sign up and we associate it to the xprofile field. Then, we could get the index of selected option and from there assign an email admin to that option. That’s the part where I’m blocked. Is this what you are suggesting to try with the “checking the $_POST global”?

    Thanks again for your help.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    that’d be my best educated guess, hoping that the value from the dropdown is still available at the time of our filter being run so that you could use that to grab the appropriate user email.

    Hi Michael,

    is there a snippet code available or some similar example that we can use as a base to start with?

    Thank you so much

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Best I can offer is a slightly modified version of what’s already present in this thread, but there’s still going to be a lot of parts you need to fill in.

    function ntp_bpro_single_admin_notice( $default_admins ) {
    	$new_admins = array();
    
    	// Return early of we're not processing a post or our intended form value isn't part of it.
    	if ( empty( $_POST ) || ! isset( $_POST['???'] ) ) {
    		return $default_admins;
    	}
    
    	// get user data here.
    	$chosen_user = sanitize_text_field( $_POST['???'] );
    
    	$new_admins[] = ???;
    
    	return $new_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'ntp_bpro_single_admin_notice' );
    

    You’re going to need to figure out the form field name in regards to what gets submitted and set in the $_POST global, and then use it to somehow get the user data enough to learn their email. Then just the email value would be inserted into the $new_admins array and returned.

    Any spot with “???” is something i don’t have the ability to know at this point.

    I came upon this thread when searching for an answer to a similar question. I attempted the suggested code in a custom plugin:

    
    function gpp_bpro_single_admin_notice( $default_admins ) {
    	// BuddyPress Registration Options will be expecting an array.
    	$new_admins = array();
    
    	// So we will return an array with one item, the admin_email setting.
    	$new_admins[] = '[email protected]';
    
    	return $new_admins;
    }
    add_filter( 'bprwg_bp_notification_users', 'gpp_bpro_single_admin_notice' );
    

    However the email notification to this address simply did not trigger, and I am not seeing any errors in the logs when I attempt to trigger it by generating a new user registration. Any thoughts?

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