Awesome Support Documentation

Hooks and Filters

Note: This document is no longer being updated.  Instead you can find a more extensive list of hooks and filters on our developers portal at developer.getawesomesupport.com

General Filters and Action Hooks

Filter: wpas_before_submit_new_ticket_checks

add_filter( ‘wpas_before_submit_new_ticket_checks’, array( $this, ‘check_required_fields’ ) );

Use this filter to control whether to accept or reject a ticket when the ticket is being submitted on the front-end. An example of using filter this can be found in our Power-pack add-on (class_misc_options.php)

Filter: wpas_get_custom_fields

apply_filters( ‘wpas_get_custom_fields’, $this->options )

Use this to modify the custom fields array/data before it is returned to the calling function/program.  An example of using filter this can be found in our Power-pack add-on (class_misc_options.php)

Tip: Each custom field in the array has an attribute named ‘order’.  This attribute controls the order in which the custom fields will be rendered on the ticket form.  So, your filter function can modify this attribute for each field  which will help to control the display order on the front-end ticket form.

Filter: wpas_user_profile_show_tickets

apply_filters( ‘wpas_user_profile_show_tickets’, true )

This filter is used to control whether or not a list of tickets belonging to the user is printed in the user profile metabox in wp-admin.

Example Usage

add_filter( 'wpas_user_profile_show_tickets',  'wpas_user_profile_hide_tickets', 10, 1);

function wpas_user_profile_hide_tickets( $hide_ticket ) {

    return false ; // hide tickets from the metabox.

}

Availability: 4.4.0 or later

Early Loading Filters

Filter: wpas_initiate_session_flag

$open_session = apply_filters( ‘wpas_initiate_session_flag’, true ) ;

You can use the wpas_initiate_session_flag filter to disable creating the session. This would be useful when the traffic is coming from bot sources such as pingdom or uptimerobot.

This filter needs to be defined VERY EARLY in the loading process so best to define it in a MU plugin.

Example Usage

add_filter('wpas_initiate_session_flag', 'wpas_filter_bots', 10, 2);

function wpas_filter_bots($result) {

    // manipulate the $result variable here to set it to true or false.

    return $result;

}

Availability: 4.3.1 or later

Filter: wpas_allow_loading

$load_allowed = apply_filters( ‘wpas_allow_loading’, true ) ;

You can use this filter to completely prevent Awesome Support from loading. This would be useful when the traffic is coming from bot sources such as pingdom or uptimerobot.

This filter needs to be defined VERY EARLY in the loading process so best to define it in a MU plugin.

Example Usage

add_filter('wpas_allow_loading', 'wpas_allow_load', 10, 2);

function wpas_allow_load($result) { 

    // manipulate the $result variable here to set it to true or false.

    return $result;

}

Availability: 4.3.3 or later

Filter: wpas_allow_soft_loading

$load_allowed = apply_filters( ‘wpas_allow_soft_loading’, true ) ;

You can use this filter to completely prevent Awesome Support from loading. This would be useful when the traffic is coming from bot sources such as pingdom or uptimerobot.  This filter is very similar to the wpas_allow_loading filter except when it fails, it uses a RETURN statement instead of a DIE statement. This allows other scripts to run instead of killing everything, which might not be what you want to do.

This filter needs to be defined VERY EARLY in the loading process so best to define it in a MU plugin.

Example Usage

add_filter('wpas_allow_soft_loading', 'wpas_allow_load', 10, 2);

function wpas_allow_load($result) { 

    // manipulate the $result variable here to set it to true or false.

    return $result;

}

Availability: 4.3.3 or later

Filters and Hooks Related To User And Account Creation

These filters and hooks are generally available during the user registration process

Filter: wpas_insert_user_data

$args = apply_filters( ‘wpas_insert_user_data’, array(
‘user_login’ => $username,
‘user_email’ => $user[’email’],
‘first_name’ => $user[‘first_name’],
‘last_name’ => $user[‘last_name’],
‘display_name’ => “{$user[‘first_name’]} {$user[‘last_name’]}”,
‘user_pass’ => $user[‘pwd’],
‘role’ => ‘wpas_user’,
) );

This filter can be used to change the data for the user / account just before it is passed to WordPress.

Example Usage

function wpas_my_set_username( $args ) {
// set the user login name to the user email address
$args['user_login'] = $args['user_email'];
return $args;
}
add_filter('wpas_insert_user_data', 'wpas_my_set_username', 10, 1);

Availability: 3.1.5 or later

Filter: wpas_register_account_errors

$user_id = apply_filters( ‘wpas_register_account_errors’, $user_id, $args[‘first_name’], $args[‘last_name’], $args[‘user_email’] )

This filter can be used to perform custom checks on the data being sent to WordPress during the account creation process. Return an WP_ERROR object to prevent the account from being created!

Availability: 3.2.0 or later

Action: wpas_insert_user_before

do_action( ‘wpas_insert_user_before’, $args );

This action hook is called just before the account creation process (but after all error checking has been completed and everything is good to go)

Availability: 3.2.0 or later

Action: wpas_insert_user_after

do_action( ‘wpas_insert_user_after’, $user_id, $args );

This action hook is called just after the account creation process

Availability: 3.2.0 or later

Filter: wpas_new_user_notification

apply_filters( ‘wpas_new_user_notification’, $notify )

This filter can be used to return a boolean that turns on/off new user notification emails.

Availability: 3.2.0 or later

Filters and Hooks Related To Ticket Security

These filters and hooks are generally available when a ticket is being viewed.

Filter: wpas_can_view_ticket

apply_filters( ‘wpas_can_view_ticket’, $can, $post_id, $author_id );

This filter can be used to control whether the current ticket being accessed can be viewed by the current user (front-end user or back-end agent).  The return value is a BOOLEAN.

Example Usage

function wpas_my_ticket_view_control( $can ) {
// force all tickets to be viewable by all users
return true;
}
add_filter('wpas_can_view_ticket', 'wpas_my_ticket_view_control', 10, 1);

Availability: 4.4.0 or later

Filters and Hooks Related To Closing Tickets

These filters and hooks are generally available when a ticket is being closed.

Action: wpas_after_close_ticket

do_action( ‘wpas_after_close_ticket’, $ticket_id, $update, $user_id );

This action hook gets fired after a ticket is closed.

Example Usage

function wpas_my_after_close_ticket( $ticket_id, $update, $user_id ) {
// log the ticket being closed...
error_log( 'closing ticket: ' . (string) $ticket_id ) ;
}
add_action('wpas_after_close_ticket', 'wpas_my_after_close_ticket', 10, 3);

Availability: 3.0 or later

Action: wpas_ticket_before_close_by_agent

do_action( ‘wpas_ticket_before_close_by_agent’, $post_id );

This action hook gets fired before a ticket is closed by the agent – as long as the agent also provides a reply at the same time as they are closing the ticket.

Example Usage

function wpas_my_ticket_before_close_by_agent( $ticket_id ) {
// log the ticket being closed...
error_log( 'closing ticket: ' . (string) $ticket_id ) ;
}
add_action('wpas_ticket_before_close_by_agent', 'wpas_my_ticket_before_close_by_agent', 10, 1);

Availability: 3.0 or later

Action: wpas_ticket_closed_by_agent

do_action( ‘wpas_ticket_closed_by_agent’, $post_id );

This action hook gets fired after a ticket is closed by the agent – as long as the agent also provides a reply at the same time as they are closing the ticket.

Example Usage

function wpas_my_ticket_closed_by_agent( $ticket_id ) {
// log the ticket being closed...
error_log( 'closing ticket: ' . (string) $ticket_id ) ;
}
add_action('wpas_ticket_closed_by_agent', 'wpas_my_ticket_closed_by_agent', 10, 1);

Availability: 3.0 or later

 

*** End of Document ***