Developer hooks

Where to add custom code

If you use a hook to add or manipulate code, you can add your custom code in a variety of ways:

  • To a custom child theme’s functions.php  file.
  • Using a plugin such as Code Snippets.

CRM-specific hooks

Each CRM format we support comes with it's own set of hooks.

Check out the CRM-specific guides for details on these hooks.

Hooks used across all formats

The below hooks are applied regardless of format:

Hook name: propertyhive_before_property_import_cron

Hook type: Action

Description: Executed right at the beginning before anything else when a property import begins

Example usage:

add_action( 'propertyhive_before_property_import_cron', 'before_import' );
function before_import()
{
    // do something here...
}

Hook name: propertyhive_after_property_import_cron

Hook type: Action

Description: Executed right at the end of an import process running.

Example usage:

add_action( 'propertyhive_after_property_import_cron', 'after_import' );
function after_import()
{
    // do something here...
}

Hook name: propertyhive_property_import_keep_logs_days

Hook type: Filter

Description: Customise how long import logs are kept for. Defaults to 7 days.

If you have thousands of properties with imports running every 15 minutes, you're going to end up with a lot of log entries in the database. Consider reducing the number of days in this case.

Example usage:

add_filter( 'propertyhive_property_import_keep_logs_days', 'keep_logs_days' );
function keep_logs_days( $days )
{
    // $days (int) - Number of days to keep the logs. Defaults to 7
    
    return 3;
}

Hook name: propertyhive_property_import_include_deleted_in_filter

Hook type: Filter

Description: On the main properties list you'll have the ability to filter by which import originally imported the properties.

This list will also include deleted imports by default. Use this filter to ensure deleted imports are not included in this filter.

Example usage:

add_filter( 'propertyhive_property_import_include_deleted_in_filter', 'show_deleted' );
function show_deleted( $show )
{
    // $show (bool) - Whether to show deleted imports in filter. Defaults to true
    
    return false;
}

Hook name: propertyhive_property_imported

Hook type: Action

Description: Executed after each individual property is imported.

Example usage:

add_action( 'propertyhive_property_imported', 'property_imported', 10, 2 );
function property_imported()
{
    // $post_id (int) - the WordPress post ID of the imported property
    // $property (SimpleXML object|array) - The property received from the CRM

    // do something here...
}

Each CRM format has their own individual version of this hook should you want to target a specific format.

More about this in the 'Developer Hooks' section of each CRM-specific guide.