How to Add Custom Checks to the Ticket Submission Process

Example

<?php
add_filter( ‘wpas_before_submit_new_ticket_checks’, ‘wpas_extra_submission_check’ );
/**
* Add extra verifications to the ticket submission process
*
* @param bool|WP_Error $go The submission authorization status
* @return bool|WP_Error
*/
function wpas_extra_submission_check( $go ) {
// Check something
if ( 1 !== 2 ) {
/**
* If the check fails, we create an error to display to the user.
* The $go variable could potentially be errored already (from a custom field for instance), in which case
* we don’t want to override the existing errors. For that reason, we only create a WP_Error object if $go
* isn’t one already.
*/
// Make sure $go is not already errored
if ( ! is_wp_error( $go ) ) {
$go = new WP_Error();
}
// Add a custom error message
$go->add( ‘custom_error_code’, ‘Explanation of why the submission fails (will be displayed to the user)’ );
}
return $go;
}
view rawwpas-check.php hosted with ❤ by GitHub
Smart Chat
Smart Replies add-on Chat X