fbpx

How can we help?

Remove the Preview Step

WP Event Manager Tutorial on Remove the Preview Step is useful in Event Submission

The event submission can be further simplified by remove the preview steps.

You need to do the following things:

  • Remove the Preview step.
  • Change preview text to ‘Submit Event’.
  • Manually publish event (from admin panel or based on settings, it will auto publish).

Add the following code to your functions.php to accomplish that:

<?php
/**
 * Remove the preview step. Code goes in theme functions.php or a custom plugin.
 * @param  array $steps
 * @return array
 */
function custom_submit_event_steps( $steps ) {
    unset( $steps['preview'] );
    return $steps;
}
add_filter( 'submit_event_steps', 'custom_submit_event_steps' );


/**
 * Change button text 
 */
function change_preview_text() {
    return __( 'Submit Event','wp-event-manager' );
}
add_filter( 'submit_event_form_submit_button_text', 'change_preview_text' );


/**
 * Since we removed the preview step and its handler, we need to manually publish events
 * @param  int $event_id
 */
function submit_event_without_preview_step( $event_id ) 
{
    $event = get_post( $event_id );

    if ( in_array( $event->post_status, array( 'preview', 'expired' ) ) ) {
        // Reset expiry date
        delete_post_meta( $event->ID, '_event_expiry_date' );

        // Update event listing
        $update_event                  = array();
        $update_event['ID']            = $event->ID;
        $update_event['post_status']   = get_option( 'event_manager_submission_requires_approval' ) ? 'pending' : 'publish';
        $update_event['post_date']     = current_time( 'mysql' );
        $update_event['post_date_gmt'] = current_time( 'mysql', 1 );
        wp_update_post( $update_event );
    }
}
add_action( 'event_manager_event_submitted', 'submit_event_without_preview_step' );
?>

Was this article helpful?
How can we improve this article?