• Trippetchz

    (@trippetchz)


    Hi there,

    Thanks for this great plugin!

    I was looking at this code snippet here: https://gist.github.com/xnau/f48ef79c35c99597734724c8cf97b2e9

    Just wondering if there’s something close to this that can be added to the theme’s functions.php or something to trigger an action after a participant is approved by an admin?

    I’m looking to add a user to our Mailster mailinglist after they have been approved.

    A sketch:

    `

    add_action( 'pdb-????', 'xnau_mailinglist_signup' );
    /**
     * does something when an admin approves a participant from the wordpress dashboard
     */
    function xnau_mailinglist_signup( $post )
    {
      if ( is_admin() ) {
        // add user to mailster
      }
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author xnau webdesign

    (@xnau)

    That code doesn’t illustrate a good way to implement what you’re asking about. For something like that, you need to be able to check to see if the “approved” status is newly set, otherwise, the action will be retriggered.

    The correct filter to use for this is pdb-before_submit_update

    It is best to implement this as a custom plugin, putting code like this in the functions.php runs the risk of it not working (plugins are run before the functions.php script is run) and it’s more portable…always a good thing.

    Your filter function will need to return the incoming data (otherwise the update won’t take place). To trigger the action, it needs to check the current record against the incoming data to see if the approved field is getting changed. The incoming array of data will include an ‘id’ field, which you can use to get the currently saved record values using Participants_Db::get_participant( $data['id'] ).

    I’m sorry I don’t have some example code to show you.

    Thread Starter Trippetchz

    (@trippetchz)

    Hi there,

    Thanks for getting back and for the suggestions.

    If I get anything working, I’ll share it here. ??

    Thanks,
    tr

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom code after a participant is approved’ is closed to new replies.