WordPress.org

Forums

CampTix Event Ticketing
[resolved] Need email sent to event organizer (10 posts)

  1. starent1
    Member
    Posted 2 years ago #

    I just realized during testing that this has no option for sending an email to an event organizer, letting know that new tickets have been purchased.

    Any chance you could help me figure out how to get that to happen? I'm not opposed to editing the code, if you don't want to update the main plugin with this, but would be VERY helpful, and can be as simple as "New tickets have been purchased. Please login at domain.com to view the info." Or, at the very least, simply sending a copy of the receipt email to event organizer would work.

    Thanks!

    http://wordpress.org/extend/plugins/camptix/

  2. Konstantin Kovshenin
    Member
    Plugin Author

    Posted 2 years ago #

    You can do that with an action to transition_post_status and the wp_mail function to send an e-mail. You can learn more here: http://codex.wordpress.org/Post_Status_Transitions

  3. starent1
    Member
    Posted 2 years ago #

    Thanks for pointing me there; and while I love learning new things, my timeframe is tight. Unfortunately, I don't know this type of stuff well, and need to get this site online asap.

    Any chance you would be willing to provide some code to get this done, referencing only the attendee post type?

    I would be willing to compensate you for your time, if necessary.

    Thank so much!

  4. starent1
    Member
    Posted 2 years ago #

    Ok, I was more ambitious than I figured... I plugged this into the functions.php:

    // function to be executed when custom post type tix_attendee is published
    function new_registration_notify() {
    		$message = "Message...";
    		$headers = 'From: Who From <from@emailaddress.com>' . "\r\n";
    		wp_mail('to@emailaddress.com', "Subject...", $message, $headers);
    }
    
    	add_action('publish_tix_attendee', 'new_registration_notify');

    This actually seems to work! However, I'm receiving two copies of the email for some reason. Any idea why?

  5. Konstantin Kovshenin
    Member
    Plugin Author

    Posted 2 years ago #

    Not sure, but that action is fired in wp_transition_post_status, and my guess is that it's also fired for publish to publish transitions, so what you'd need is the other action called transition_post_status. Off the top of my head:

    function my_transition( $new, $old, $post ) {
        if ( $new == $old || $new != 'publish' || $post->post_type != 'tix_attendee' )
            return;
    
        // do your stuff
    }
    add_action( 'transition_post_status', 'my_transition', 10, 3 );
  6. starent1
    Member
    Posted 2 years ago #

    When I switch to your code, I get the following in browser after submitting the form online:

    Warning: Missing argument 2 for new_registration_notify() in /.../wp-content/themes/<theme>/functions.php on line 726

    Note in case it's in question: I did replace "\\do your stuff" with the wp_mail code.

  7. Konstantin Kovshenin
    Member
    Plugin Author

    Posted 2 years ago #

    Can you post the exact code you're trying to use?

  8. starent1
    Member
    Posted 2 years ago #

    I replaced "\\do your stuff" with the wp_mail code that worked using the originally-posted function (only that one sent it twice).

  9. Konstantin Kovshenin
    Member
    Plugin Author

    Posted 2 years ago #

    Just paste the code that you're using :)

  10. starent1
    Member
    Posted 2 years ago #

    Ok, I must have fat-fingered something the first time. Works perfectly!

    Thank you very much for taking the time to answer this for me.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • CampTix Event Ticketing
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.