Skip to content

Commit

Permalink
redirect to error page if submission error
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq1988 committed Oct 10, 2015
1 parent 35835d0 commit c4ccd5f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions templates/form-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,21 @@ public function handle_form() {
// New or edit?
if ( ! $field_id ) {

%prefix%_insert_%singular_name%( $fields );
$insert_id = %prefix%_insert_%singular_name%( $fields );

} else {

$fields['id'] = $field_id;

%prefix%_insert_%singular_name%( $fields );
$insert_id = %prefix%_insert_%singular_name%( $fields );
}

if ( is_wp_error( $insert_id ) ) {
$redirect_to = add_query_arg( array( 'message' => 'error' ), $page_url );
} else {
$redirect_to = add_query_arg( array( 'message' => 'success' ), $page_url );
}

$redirect_to = add_query_arg( array( 'affected' => $affected ), $page_url );
wp_safe_redirect( $redirect_to );
exit;
}
Expand Down

0 comments on commit c4ccd5f

Please sign in to comment.