Hooks and filters
Hooks and filters
The actions and filters PremiumPress offers for your own code, grouped by area. Every name starts with ppt_.
How to use them
They work like any WordPress hook. Put your code in a child theme's functions.php or in your own plugin.
// A filter changes a value and returns it.
add_filter('ppt_search_radius_default', function ($distance) {
return 50;
});
// An action runs your code at a moment or a place on the page.
add_action('ppt_message_sent', function ($from, $to, $messageId, $isNewConversation) {
// e.g. tell your CRM
}, 10, 4);
In the tables, A is an action and F is a filter. "Receives" lists the arguments in order; pass the matching count as the fourth argument of add_action / add_filter when it is more than one.
This page lists the hooks meant for your code. The theme fires others for its own internal use; those can change between versions without notice, so do not build on them.
Some listing-page and editor hooks only fire on products that use the shared listing page and editor: see Product differences at the end.
Listings
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_listing_after_title | A | listing ID | Print something under the listing title |
ppt_listing_after_sections | A | listing ID, heading builder | Add your own section after the listing's sections (example) |
ppt_single_sidebar_top | A | listing ID | Print something at the top of the listing sidebar |
ppt_listing_title_badges | F | HTML, listing ID | Add badges beside the title |
ppt_listing_detail_value | F | value, field key, listing ID | Change how a detail row's value is shown |
ppt_listing_card_data | F | card data, options | Change the data a listing card is drawn from |
ppt_listing_card_html | F | null, card data, options | Return your own HTML for a whole listing card |
ppt_listing_gallery | F | photos, listing ID | Change the photos shown |
ppt_listing_videos | F | videos, listing ID | Change the videos shown |
ppt_listing_faq | F | FAQ items, listing ID | Change a listing's questions and answers |
ppt_listing_pricing_plans | F | rows, listing ID | Change a listing's price list |
ppt_listing_business_schema | F | JSON-LD node, listing ID | Change the structured data search engines read |
ppt_related_count | F | number | How many related listings to show |
ppt_single_template | F | path, theme type, original path | Use your own listing-page template (Page layouts) |
ppt_listing_reported | A | listing ID, reason | A visitor reported a listing |
ppt_listing_claim_submitted | A | listing ID, user ID, claim ID | A business claim was sent |
ppt_listing_claim_approved | A | listing ID, user ID, claim ID | A claim was approved |
ppt_listing_claim_denied | A | listing ID, user ID, claim ID | A claim was turned down |
ppt_listing_cloned | A | new ID, source ID, photos copied | A listing was duplicated |
ppt_listing_clone_meta_keys | F | meta keys | Which fields are copied when duplicating |
ppt_listing_expired_by_admin | A | listing ID | An administrator expired a listing |
ppt_review_card_after_text | A | listing ID, comment | Add to a review card under its text |
The listing editor
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_listing_form_cards | A | listing ID, 'admin' or 'member' | Print your own card at the end of the editor |
ppt_listing_editor_saved | A | listing ID, posted form, 'admin' or 'member' | Save your card's fields |
ppt_listing_editor_notices | A | listing ID, 'member' | Print a notice above the member's editor |
ppt_listing_member_can_add | F | yes/no, user ID | Decide whether a member may add a listing |
ppt_social_networks | F | networks | The social networks a listing can link to |
ppt_listing_max_tags | F | number | The most tags a listing can have |
ppt_listings_multi_category | F | yes/no | Allow more than one category per listing |
ppt_listings_category_list | F | categories | The categories offered in the picker |
A worked example of an editor card is in Adding your own features.
Search and maps
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_search_before_grid | A | Print something above the results | |
ppt_search_after_heading | A | Print something under the results heading | |
ppt_category_before_results / ppt_category_after_results | A | Print something around a category's results | |
ppt_search_sidebar | A | Print something in the search sidebar | |
ppt_search_sort_options | F | options | Add, rename or remove sort choices |
ppt_search_default_sort | F | sort key | The sort used when none is chosen |
ppt_search_radius_default | F | distance (25) | The default distance for location searches |
ppt_distance_unit | F | 'km' | Show distances in 'km' or 'mi' |
ppt_search_price_bounds | F | range, post type | The price slider's range |
ppt_search_visible_filters | F | number | How many filters show before "More filters" |
ppt_search_rail_fields | F | fields | The filters in the filter panel |
ppt_search_map_points | F | pins | Change the map pins |
ppt_ads_between_after | F | number | Show an ad after every N results |
ppt_maps_provider | F | 'osm' | Use 'osm', 'google' or 'mapbox' maps |
Members and accounts
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_login_redirect | F | URL, user | Where members go after signing in |
ppt_signup_done_redirect | F | URL, user ID | Where new members go after signing up |
ppt_signup_steps | F | step keys, profile | Change the sign-up steps |
ppt_free_email_domains | F | domains | The free-mail domains blocked when "business emails only" is on |
ppt_terms_url / ppt_privacy_url | F | URL | Your terms and privacy pages |
ppt_account_verified | A | user ID, method | A member finished verifying their account |
ppt_account_type_changed | A | user ID, new type, old type | A member changed account type |
ppt_hub_nav_extend | A | groups, tab map, user ID, listings | Add a group or tab to the member area menu |
ppt_hub_extra_panels | F | HTML, user ID, listings, default tab | Return the content of your member-area tab |
ppt_hub_overview_side | A | user ID | Add a card to the member area overview |
ppt_hub_listing_row_actions | A | listing ID, post | Add buttons to each row of "My listings" |
ppt_hub_account_rows | A | user ID, icon | Add rows to the Account panel |
ppt_author_profile_cover / _meta / _body | A | author ID | Add to an author's public profile |
ppt_message_sent | A | sender ID, recipient ID, message ID, new conversation | A message was sent |
ppt_seller_follow_changed | A | seller ID, follower ID, following | Someone followed or unfollowed |
ppt_saved_search_added | A | user ID, saved search | A member saved a search |
ppt_membership_renewed | A | order ID, user ID, plan, new expiry | A membership renewed |
ppt_membership_cancelled | A | order ID, user ID | A membership was cancelled |
ppt_memberships_url | F | URL | The page that lists membership plans |
The member-area hooks are used in Adding your own features.
Checkout and payments
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_payment_gateways | F | gateways | Register a payment gateway (Writing a payment gateway) |
ppt_gateway_start | F | null, gateway ID, order, return URL | Send the buyer to your payment page |
ppt_gateway_verify | F | null, gateway ID, order details | Confirm a payment |
ppt_checkout_item_paid | A | item, order ID, user ID | Something was paid for |
ppt_publish_paid_listing | F | yes/no, listing ID, order ID | Publish a listing straight after payment, or not |
ppt_subscription_cancelled | A | order ID, listing ID | A listing subscription was cancelled |
ppt_order_type_label | F | label, order type | The name of an order type in the admin |
ppt_shipping_providers | F | providers | Register a shipping-rate provider |
ppt_shipping_rate_quote | F | null, provider ID, shipment | Return shipping rates |
ppt_booking_created | A | booking ID, listing ID, booker ID, name | A booking was made |
Emails and notifications
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_email_catalog | F | templates | Add your own email templates |
ppt_email_groups | F | groups | Add a section to the Emails screen |
ppt_email_should_send | F | yes/no, template key, recipient, tokens | Stop a particular email |
ppt_email_sent | A | template key, recipient, tokens, sent | An email was sent |
ppt_notification | A | user ID, type, title, URL, text | An on-site notification was created |
ppt_send_sms | A | phone number, message | Fire this to send a text message |
ppt_subscriber_added | A | email, name, source, ID | Someone joined the newsletter |
Header, footer and pages
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_after_announce | A | Print something under the announcement bar | |
ppt_header_actions | A | Add to the header's buttons area | |
ppt_header_cta_text / ppt_header_cta_url | F | text / URL | Change the header's main button |
ppt_brand_name | F | name | The site name shown in the header |
ppt_footer_links | F | links | The footer's links |
ppt_build_menu_item | F | menu item | Change a menu item as it is built |
ppt_page_slugs | F | slugs | The web addresses of the theme's built-in pages |
ppt_blog_title / ppt_blog_subtitle | F | text | The blog page's heading |
ppt_redirect_destinations | F | destinations | Pages offered on the Redirection screen |
ppt_enable_analytics | F | yes/no | Turn the theme's analytics output off |
ppt_asset_base | F | base URL | Serve the theme's files from your own CDN |
ppt_countries | F | countries | The country list |
ppt_phone_initial_country | F | country code | The default country in phone fields |
Blocks and designs
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_blocks | F | block classes | Register your own homepage blocks (how) |
ppt_designs | F | design classes | Register your own full-page designs |
Admin
| Hook | Receives | Use it to | |
|---|---|---|---|
ppt_listing_setup_sections | A | Add a section to Listings ▸ Setup | |
ppt_member_edit_cards | A | user ID, member | Add a card to the admin's member screen |
ppt_email_settings_cards | A | Add a card to the email settings | |
ppt_default_fields | F | fields | The factory set of custom fields used by Reset and new installs |
Product differences
A few hooks depend on which product you run:
ppt_listing_form_cardsfires in the Directory Theme's listing editor. Products with their own editor do not fire it yet.ppt_listing_after_title,ppt_listing_after_sectionsandppt_single_sidebar_topfire on the shared listing page. The Coupon, Shop, Classifieds, Dating, Video, Escort, Cashback and Comparison themes draw their own listing page and do not fire them.ppt_hub_nav_extendandppt_hub_extra_panelsare not fired in the Dating, Escort and Video themes' member areas.
Each product also fires hooks of its own (for example ppt_jb_application_made in the Job Board Theme, or ppt_bid_recorded in the Auction Theme). If you need one of those, ask support and we will point you to it.