> For the complete documentation index, see [llms.txt](https://documentation.ajaxsearchpro.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.ajaxsearchpro.com/plugin-api/actions-list-and-usage.md).

# Actions list and usage

Actions are triggered by specific events that take place in the plugin code.

## Usage examples

```
/**
 * Example 1
 *
 * This function will save the search phrase to the database
 */
add_action( 'asp_before_search', 'asp_change_phrase', 10, 1);

function asp_change_phrase( $phrase ) {
  update_option('asp_search_phrase', $phrase);
}

/**
 * Example 2
 * 
 * This function will print "Hi!" header before the search shortcode. 
 */
add_action( 'asp_layout_before_shortcode', 'asp_print_before_shortcode');

function asp_print_before_shortcode() {
  echo "<h3>Hi!</h3>";
}
```

More examples in the [knowledge base.](https://wp-dreams.com/knowledgebase/)

If you need more general information about hooks in WordPress, please check their [plugin API reference.](https://codex.wordpress.org/Plugin_API)

## Action hook list

```
/**
 * Functional actions 
 * 
 * Variables:
 *      $id -> the ID of the search instance
 *      $search_phrase -> holds the search phrase
 *      $results_assoc_array -> an associated array of all result objects
 *      $pageposts_assoc_array -> an associated array of posts, pages, custom post types results
 *      $commentsresults_assoc_array -> an associated array of comment results
 *      $buddypresults_assoc_array -> an associated array of buddypress results
 */

do_action('asp_before_search', $search_phrase); 
do_action('asp_after_search', $search_phrase, $results_assoc_array);

do_action('asp_after_pagepost_results', $search_phrase, $pageposts_assoc_array);
do_action('asp_after_comments_results', $search_phrase, $commentsresults_assoc_array);
do_action('asp_after_buddypress_results', $search_phrase, $buddypresults_assoc_array);

do_action('asp_before_autocomplete', $search_phrase);
do_action('asp_after_autocomplete', $search_phrase, $keyword);

/* Box, Settings etc.. layount actions */

do_action('asp_layout_before_shortcode', $id);
do_action('asp_layout_after_shortcode', $id);
do_action('asp_layout_before_input', $id);
do_action('asp_layout_after_input', $id);
do_action('asp_layout_before_magnifier', $id);
do_action('asp_layout_in_magnifier', $id);
do_action('asp_layout_after_magnifier', $id);
do_action('asp_layout_before_settings', $id);
do_action('asp_layout_after_settings', $id);
do_action('asp_layout_before_loading', $id);
do_action('asp_layout_in_loading', $id);
do_action('asp_layout_after_loading', $id);
do_action('asp_layout_settings_before_first_item', $id);

/* Template related actions */

// Vertical layout
do_action('asp_res_vertical_begin_item');
do_action('asp_res_vertical_before_image');
do_action('asp_res_vertical_after_image');
do_action('asp_res_vertical_after_content');
do_action('asp_res_vertical_end_item');

// Horizontal layout
do_action('asp_res_horizontal_begin_item');
do_action('asp_res_horizontal_after_image');
do_action('asp_res_horizontal_after_content');
do_action('asp_res_horizontal_end_item');

// Isotopic layout
do_action('asp_res_isotopic_begin_item');
do_action('asp_res_isotopic_after_image');
do_action('asp_res_isotopic_after_content');
do_action('asp_res_isotopic_end_item');
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.ajaxsearchpro.com/plugin-api/actions-list-and-usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
