mercredi 6 avril 2016

(PHP) Explain this code

First time editing a wordpress plugin. I followed a tutorial online to put this codes into my theme's function.php file:

add_action( 'action_hook_espresso_insert_event_success', 'wdm_create_waitlist_event', 10, 1 );   function wdm_create_waitlist_event($_REQUEST) {
     $original_event_id = $_REQUEST['event_id'];
     $waitlist_event_name = $_REQUEST['event'].' Waitlist';
     add_event_to_db();
     $waitlist_event_id = $_REQUEST['event_id'];
     $wpdb->query( $wpdb->prepare( "UPDATE ".EVENTS_DETAIL_TABLE." SET event_status=%s, event_name=%s WHERE id=%d", 'S', $waitlist_event_name, $waitlist_event_id ) );
     $wpdb->query( $wpdb->prepare( "UPDATE ".EVENTS_DETAIL_TABLE." SET allow_overflow=%s, overflow_event_id=%d WHERE id=%d",'Y', $waitlist_event_id, $original_event_id ) );   }

They are codes that are suppose to automate a waitlist for event creation.

BUT what happened instead:

it duplicated >1000 over entries of an event.

I got a feeling it has to do with the "10, 1", can anyone explain why this happened?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire