Send Admin Emails to Other User

This topic contains 6 replies, has 3 voices, and was last updated by  TS 10 years, 2 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #9287

    If someone books an event normally the admin gets an email saying that someone signed up for their event. However, is it possible to change who gets these emails? Say a user for the site and not the admin for the site?

    Nicholas Williams
    #9295

    Yes you can (since 1.5), here’s an example which e-mails the event organiser as well as the admin:

    add_filter( 'eventorganiser_booking_notification_email', 'my_booking_notification_email', 10, 2 );
    function my_booking_notification_email( $emails, $booking_id ){
    
          //Get the event ID and organiser ID
          $event_id = eo_get_booking_meta( $booking_id, 'event_id' );
    
          //Get the event's organiser
          $organiser_id = get_post_field( 'post_author' $event_id );
          $user_obj = get_userdata( $organiser_id );
    
          //If the user exists, add their email to notify both organiser and admin
          if( $user_obj ){
              $emails[] = $user_obj->user_email;
          }
    
          return $emails;        
    }
    • This reply was modified 10 years, 3 months ago by  Stephen Harris.
    Stephen Harris
    #9448

    Is this something I add to my functions.php file or is it supposed to be added to the plugin somewhere?

    Nicholas Williams
    #9456

    You can add it to functions.php. Though it’s preferable that this would live inside a site ‘utility’ plug-in. There’s more details on this here: wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/

    Stephen Harris
    #9570

    Hi Stephen,

    Further to Nicholas’ question, is there any way to stop administrators from receiving the notifications, AND also change the event creator?

    Our WordPress setup involves an administrator account and a client account; during development, most events were set up by the administrator account – but we do not need to know when our client receives bookings. Post-development we just manage the WordPress install and plugin updates, and let the clients control the rest.

    Ideally we’d like to keep our admin email address intact and let the client receive booking notifications to their own address.

    Thanks, appreciate any guidance you can share.

    TS
    #9596

    Hi Tracy,

    On the event admin page there is a metabox “Event Organiser” which allows you to select from a dropdown of available users. Those users must be able to edit events (see Settings > Event Organiser > Permissions). Your side admin can set the appropriate user to be the event organiser.

    The above snippet adds the event organiser’s email address to the “admins” that are notified when a booking is made (I say admins, because this is not the e-mail sent to the bookee). To prevent the site admin from being notified you can remove their email address, or just replace the array of emails with one that only includes the event organiser’s email.

    E.g. in the above snippet replace

    $emails[] = $user_obj->user_email;

    with

    $emails = array( $user_obj->user_email );
    Stephen Harris
    #9632

    Thanks so much Stephen, I appreciate it.

    I couldn’t find the author anywhere, then I had my morning coffee and realised I’d unticked the option to show it in the admin. Oops. But at least that’s sorted now. 😉

    Will see how we go now. Thanks again.

    TS
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.