Business Directory Plugin offers plugin and theme developers the ability to hook into some of our processes and templates using WordPress actions.
Using general hooks custom processes can be included within Business Directory normal execution. Using template hooks extra HTML or output can be displayed on certain specific pages. When you make changes using hooks, they will not be overwritten with plugin updates.
How to use hooks?
Since our hooks are just regular WordPress actions, you can learn more in the WordPress Plugin API and with the add_action() function in particular.
To create a new plugin, follow these steps:
- Install Pluginception from the WP.org repository. Go to Plugins → Add New. Enter Pluginception in the search field, hit Enter. A plugin written by Otto should appear.
- Install and activate this plugin
- From the WP Admin area, go to the Plugins menu and click on Create New Plugin. We're going to create a plugin with a PHP file that you can put in the custom code. This way, your changes will never be lost.
- After that, you'll be on a screen with a lot of fields. You only need to fill out the FIRST one:
Give the plugin a name like “Business Directory Plugin – Customizations”, like this:
Then save your file at the bottom.
- You should be redirected to the Plugin Editor where you can edit the code of the plugin.
If you are not redirected, from the Plugins menu again, click Plugin Editor. Then, on the right hand side of the screen, find “Business Directory Plugin – Customizations”. This should open a BLANK PHP file.
- On the editor, paste your code at the bottom of the file (before any ?> closing tags.)
Save the PHP file by clicking Update File.
Examples
General Actions
Hook Name | Description | Arguments | Module |
---|---|---|---|
wpbdp_save_listing |
Fired after a listing has been saved into the database. | $listing_id (int) – The listing ID. $context (bool) – Listing save context, true for new listings, false for edited listings. |
BD Core Plugin 5.0 |
wpbdp_add_listing |
Fired after a listing has been created and saved into the database. | $listing_id (int) – The inserted listing ID. |
BD Core Plugin 5.0 |
wpbdp_edit_listing |
Fired after a listing has been edited in the frontend and saved in the database. This action is not fired when a listing has been edited in WP Dashboard. | $listing_id (int) – The edited listing ID. |
BD Core Plugin 5.0 |
wpbdm_listing_claimed |
Fired after claim listing process is finished. | $listing_id (int) – The claimed listing ID. $claim_id (int) – The claim ID. |
Claim Listings 5.1.2 |
wpbdm_claim_approved |
Fired after admin approves a listing claim. | $listing_id (int) – The claimed listing ID. $claim_id (int) – The claim ID. |
Claim Listings 5.1.2 |
Template Actions
Hook Name | Description | Arguments |
---|---|---|
wpbdp_checkout_form_top |
Fired at the top of the checkout form. Used by the Discount Codes module to display its discount field. | $payment (object) – The payment object. |
wpbdp_checkout_form_bottom |
Fired at the bottom of the checkout form. | $payment (object) – The payment object. |
wpbdp_before_render_receipt |
Fired before rendering the receipt during the checkout process. | $payment (object) – The payment object. |
wpbdp_after_render_receipt |
Fired after rendering the receipt during the checkout process. | $payment (object) – The payment object. |
wpbdp_before_search_results |
Fired before rendering the search results. Only when there are results. | |
wpbdp_after_search_results |
Fired after rendering the search results. Only when there are results. | |
wpbdp_before_category_page |
Fired before rendering the category page. | $category (object) – The current category. A WP_Term object. |
wpbdp_after_category_page |
Fired after rendering the category page. | $category (object) – The current category. A WP_Term object. |
wpbdp_before_submit_listing_page |
Fired before rendering the submit listing page. | $listing (object) – An object with information about the current listing being submitted or edited. |
wpbdp_after_submit_listing_page |
Fired after rendering the submit listing page. | $listing (object) – An object with information about the current listing being submitted or edited. |