Action & Filter Hooks Snippets

This page provides code snippets demonstrating how to use action and filter hooks in Greyd.Suite. The examples complement the hook reference and illustrate practical ways to extend or adapt functionality beyond what is described in the user-facing documentation.

  • More in this section

Conditional Content Custom Filter

The Conditional Content feature supports custom conditions that can be defined by other plugins or child themes. This allows developers to extend the available logic beyond the built-in options by registering their own evaluation methods. Options When selecting the condition type in the Conditional Content settings, the following options are available: Default (greyd_conditional_content_filter) – Uses […]

Read more

Global Content Filter Snippets

The following examples demonstrate how you might hook into these filters in your own plugin. Each example assumes that the Greyd Global Content plugin is active. For a full list of available filters, see the Global Content Filters documentation. Add a Custom Property to the Global Post Object PHPCopy// Add a custom field to every […]

Read more

Greyd Forms Actions Snippets

Here are two examples of how you can use the Greyd Form Actions. Excecute code before saving an entry PHPCopyfunction greyd_forms_action_before_entry_example( $form_data, $form_id ) { $form = get_post( $form_id ); if ( $form && $form->post_name === 'my-contact-form' ) { $option_value = get_option( 'my_custom_option' ); do_action( 'greyd_forms_log', $option_value, 'Custom option value' ); if ( $option_value === […]

Read more

Greyd Forms Filter Snippets

Here you can find some code snippets to use with Greyd Forms Filters. Modifying form validation PHPCopyadd_filter( 'greyd_forms_required_fields', function( $required_fields, $post_id, $data ) { // Add custom required field logic if ( $post_id === 123 ) { $required_fields[] = 'my-custom-meta-field'; } return $required_fields; }, 10, 3 ); Render a custom field at the end of […]

Read more

Post Export Filter Snippets

The following examples illustrate how third‑party developers can use these filters to extend the post export and import logic. For more information about the filters, see the Post Export Filter documentation. Customise export query arguments Exclude password‑protected posts from being exported by altering the query arguments: PHPCopyadd_filter( 'greyd_export_post_query_args', function( $query_args, $post_id, $args ) { // […]

Read more

Last updated: