Hooks - For Developers | Business Directory https://businessdirectoryplugin.com Create any kind of directory on your site, easily Thu, 20 Apr 2023 04:00:00 +0000 en-US hourly 1 https://businessdirectoryplugin.com/wp-content/uploads/2020/10/cropped-Favicon3-32x32.png Hooks - For Developers | Business Directory https://businessdirectoryplugin.com 32 32 wpbdp_button_class https://businessdirectoryplugin.com/knowledge-base/wpbdp_button_class/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_button_class Thu, 20 Apr 2023 04:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_button_class/ Add a custom class to directory buttons to help them better match other buttons on the site.

The post wpbdp_button_class first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

Add a custom class to directory buttons to help them better match other buttons on the site.

Usage

add_filter( 'wpbdp_button_class', 'add_bd_button_class' );

Parameters

  • $class (string) The classes to add. Defaults to ‘button'.

Examples

Match buttons in Astra

add_filter( 'wpbdp_button_class', 'add_bd_button_class' );
function add_bd_button_class( $class ) {
  $class .= ' ast-button';
  return $class;
}

Change Log

Added in version 6.3.4

The post wpbdp_button_class first appeared on Business Directory.]]>
wpbdp_email_from https://businessdirectoryplugin.com/knowledge-base/wpbdp_email_from/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_email_from Wed, 15 Mar 2023 04:00:00 +0000 https://businessdirectoryplugin.com/?post_type=ht_kb&p=2976492 This hook allows directory emails to be sent from an alternative email instead of the admin email.

The post wpbdp_email_from first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook allows directory emails to be sent from an alternative email instead of the admin email.

Usage

add_filter( 'wpbdp_email_from', 'change_admin_email' );

Parameters

  • $email (string)

Examples

Change sending from email

This example will change the email address that directory emails are sent from.

add_filter( 'wpbdp_email_from', 'change_admin_email' );
function change_admin_email_bloginfo( $email) {
	return 'email@example.com';
}

Change Log

Added in version 5.13

The post wpbdp_email_from first appeared on Business Directory.]]>
wpbdp_admin_listing_owner_mode https://businessdirectoryplugin.com/knowledge-base/wpbdp_admin_listing_owner_mode/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_admin_listing_owner_mode Wed, 13 Oct 2021 06:00:00 +0000 https://businessdirectoryplugin.com/?post_type=ht_kb&p=2094846 Force the user dropdown to autocomplete or not. By default, it will show the ajax list for users in the listing edit page.

The post wpbdp_admin_listing_owner_mode first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

Force the user dropdown to autocomplete or not. By default, it will show the ajax list for users in the listing edit page.

Usage

add_filter( 'wpbdp_admin_listing_owner_mode', 'wpbdp_admin_listing_owner_mode' );

Parameters

The values for the return string are either:

  • inline for inline (show all users)
  • ajax for ajax select mode (type to search for a user)

Examples

Turn of autocomplete

add_filter( 'wpbdp_admin_listing_owner_mode', 'wpbdp_admin_listing_owner_mode' );
function wpbdp_admin_listing_owner_mode( $mode ) {
	return 'inline';
}

Change Log

Added in version 5.14

The post wpbdp_admin_listing_owner_mode first appeared on Business Directory.]]>
wpbdp_custom_strings https://businessdirectoryplugin.com/knowledge-base/wpbdp_custom_strings/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_custom_strings Wed, 14 Jul 2021 06:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_custom_strings/ Automatically replace words throughout the front-end of your directory.

The post wpbdp_custom_strings first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

Automatically replace words throughout the front-end of your directory.

Usage

add_filter( 'wpbdp_custom_strings', 'bd_replace_strings' );

Parameters

$strings (array) A list of strings to replace

Examples

Replace a custom term

This example will replace the word “Region” with “Location” on the front-end of your directory.

function bd_replace_strings( $strings ) {
    $strings['Region']  = 'Location';
    $strings['Regions'] = 'Locations';
    return $strings;
}
add_filter( 'wpbdp_custom_strings', 'bd_replace_strings' );

Change Log

Added in version 5.13

The post wpbdp_custom_strings first appeared on Business Directory.]]>
wpbdp_field_schema_org https://businessdirectoryplugin.com/knowledge-base/wpbdp_field_schema_org/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_field_schema_org Fri, 12 Mar 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_field_schema_org/ This hook can be used to include or edit Schema.org items for each form field; here's an example to illustrate field filtering.

The post wpbdp_field_schema_org first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to include or edit Schema.org items for each form field; here's an example to illustrate field filtering.

Usage

add_action( 'wpbdp_field_schema_org', 'wpbdp_schema_org_fields' );

Parameters

  • $schema (array)
  • $field (object)
  • $post_id (string)

Examples

Field filtering

This example will edit some Schema.org items

add_filter('wpbdp_field_schema_org', 'wpbdp_schema_org_fields', 10, 3 );
function wpbdp_schema_org_fields( $schema, $field, $post_id ) {
    // Using field ID
    if ( 10 == $field->get_id() ) { // Replace the value 10 with the value of the field if you need
        $schema['legalName'] = $field->plain_value( $post_id );
    }

    // Using field Shortname
    if ( 'business_fax' === $field->get_shortname() ) { // Replace the business_fax value with the value of the Shortname you need
        $schema['faxNumber'] = $field->plain_value( $post_id );
    }


    return $schema;
}
The post wpbdp_field_schema_org first appeared on Business Directory.]]>
wpbdp_paid_listing_status https://businessdirectoryplugin.com/knowledge-base/wpbdp_paid_listing_status/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_paid_listing_status Wed, 03 Mar 2021 07:00:00 +0000 https://businessdirectoryplugin.com/?post_type=ht_kb&p=1380021 This hook can be used to always mark paid listings as published, regardless of default status.

The post wpbdp_paid_listing_status first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to always mark paid listings as published, regardless of default status.

Usage

add_filter( 'wpbdp_paid_listing_status', 'mark_listing_as_published' );

Parameters

  • $new_status (string)
  • $payment (array)

Examples

Mark paid listings as published

This example will mark paid listings as published, regardless of default status.

add_filter( 'wpbdp_paid_listing_status', 'mark_listing_as_published' );
function bd_mark_paid_listing_as_published( $new_status, $payment ) {
    $new_status = 'publish';
    return $new_status;
}

Change Log

Added in version 3.5.4

The post wpbdp_paid_listing_status first appeared on Business Directory.]]>
wpbdp_get_page_ids https://businessdirectoryplugin.com/knowledge-base/wpbdp_get_page_ids/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_get_page_ids Mon, 22 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/?post_type=ht_kb&p=1350910 This hook can be used to get the list of pages the plugin is used on.

The post wpbdp_get_page_ids first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to get the list of pages the plugin is used on.

Usage

add_filter( 'wpbdp_get_page_ids', 'my_custom_function' );

Parameters

  • $page_ids (array)

Examples

Flag an extra page for directories

This example will add another page to the automatic list of page ids so the plugin assets will be loaded.

add_filter( 'wpbdp_get_page_ids', 'add_another_bd_page', 10, 2 );
function add_another_bd_page( $page_ids ) {
    $page_ids[] = '25'; // add a new page id.
    return $page_ids;
}

Change Log

Added in version 5.9

The post wpbdp_get_page_ids first appeared on Business Directory.]]>
wpbdp_allow_template_override https://businessdirectoryplugin.com/knowledge-base/wpbdp_allow_template_override/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_allow_template_override Mon, 22 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_allow_template_override/ This hook can be used to prevent Business Directory from controlling the page template.

The post wpbdp_allow_template_override first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to prevent Business Directory from controlling the page template.

Usage

add_filter( 'wpbdp_allow_template_override' );

Parameters

  • $allow (bool) Defaults to TRUE

Examples

Prevent template override

This example will prevent Business Directory from overriding the template

add_filter( 'wpbdp_allow_template_override', '__return_false' );

Change Log

Added in version 5.9

The post wpbdp_allow_template_override first appeared on Business Directory.]]>
wpbdp_use_template_[template id] https://businessdirectoryplugin.com/knowledge-base/wpbdp_use_template_template-id/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_use_template_template-id Mon, 22 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_use_template_template-id/ This hook can be used to override template file.

The post wpbdp_use_template_[template id] first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to override template file.

Usage

add_filter( 'wpbdp_use_template_[template id]', 'bd_replace_template' );

Parameters

  • $path (string) Path of the file to be used to replace the template

Examples

Override template file

This example will override the ‘listings' template file.

add_filter( 'wpbdp_use_template_listings', 'bd_replace_template' );
function bd_replace_template( $path ) {
    $path = 'place here the path to the new template file';
    return $path;
}

Change Log

Added in version 5.9.2

The post wpbdp_use_template_[template id] first appeared on Business Directory.]]>
wpbdp_skip_page_1 https://businessdirectoryplugin.com/knowledge-base/wpbdp_skip_page_1/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_skip_page_1 Mon, 22 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_skip_page_1/ This hook can be used to show the first page when it's skipped (it's automatically skipped if there's only 1 category and 1 plan to choose from). If someone wants the plan to show first, use this hook

The post wpbdp_skip_page_1 first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to show the first page when it's skipped (it's automatically skipped if there's only 1 category and 1 plan to choose from). If someone wants the plan to show first, use this hook

Usage

add_filter( 'wpbdp_skip_page_1' );

Parameters

  • $skip (bool)

Examples

Show first page

This example will show the first page if it was omitted.

add_filter( 'wpbdp_skip_page_1', '__return_false' );
The post wpbdp_skip_page_1 first appeared on Business Directory.]]>