Skip to main content

Hooks and filters

10 min readApplies to every PremiumPress theme · 12.x

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​

HookReceivesUse it to
ppt_listing_after_titleAlisting IDPrint something under the listing title
ppt_listing_after_sectionsAlisting ID, heading builderAdd your own section after the listing's sections (example)
ppt_single_sidebar_topAlisting IDPrint something at the top of the listing sidebar
ppt_listing_title_badgesFHTML, listing IDAdd badges beside the title
ppt_listing_detail_valueFvalue, field key, listing IDChange how a detail row's value is shown
ppt_listing_card_dataFcard data, optionsChange the data a listing card is drawn from
ppt_listing_card_htmlFnull, card data, optionsReturn your own HTML for a whole listing card
ppt_listing_galleryFphotos, listing IDChange the photos shown
ppt_listing_videosFvideos, listing IDChange the videos shown
ppt_listing_faqFFAQ items, listing IDChange a listing's questions and answers
ppt_listing_pricing_plansFrows, listing IDChange a listing's price list
ppt_listing_business_schemaFJSON-LD node, listing IDChange the structured data search engines read
ppt_related_countFnumberHow many related listings to show
ppt_single_templateFpath, theme type, original pathUse your own listing-page template (Page layouts)
ppt_listing_reportedAlisting ID, reasonA visitor reported a listing
ppt_listing_claim_submittedAlisting ID, user ID, claim IDA business claim was sent
ppt_listing_claim_approvedAlisting ID, user ID, claim IDA claim was approved
ppt_listing_claim_deniedAlisting ID, user ID, claim IDA claim was turned down
ppt_listing_clonedAnew ID, source ID, photos copiedA listing was duplicated
ppt_listing_clone_meta_keysFmeta keysWhich fields are copied when duplicating
ppt_listing_expired_by_adminAlisting IDAn administrator expired a listing
ppt_review_card_after_textAlisting ID, commentAdd to a review card under its text

The listing editor​

HookReceivesUse it to
ppt_listing_form_cardsAlisting ID, 'admin' or 'member'Print your own card at the end of the editor
ppt_listing_editor_savedAlisting ID, posted form, 'admin' or 'member'Save your card's fields
ppt_listing_editor_noticesAlisting ID, 'member'Print a notice above the member's editor
ppt_listing_member_can_addFyes/no, user IDDecide whether a member may add a listing
ppt_social_networksFnetworksThe social networks a listing can link to
ppt_listing_max_tagsFnumberThe most tags a listing can have
ppt_listings_multi_categoryFyes/noAllow more than one category per listing
ppt_listings_category_listFcategoriesThe categories offered in the picker

A worked example of an editor card is in Adding your own features.

Search and maps​

HookReceivesUse it to
ppt_search_before_gridAPrint something above the results
ppt_search_after_headingAPrint something under the results heading
ppt_category_before_results / ppt_category_after_resultsAPrint something around a category's results
ppt_search_sidebarAPrint something in the search sidebar
ppt_search_sort_optionsFoptionsAdd, rename or remove sort choices
ppt_search_default_sortFsort keyThe sort used when none is chosen
ppt_search_radius_defaultFdistance (25)The default distance for location searches
ppt_distance_unitF'km'Show distances in 'km' or 'mi'
ppt_search_price_boundsFrange, post typeThe price slider's range
ppt_search_visible_filtersFnumberHow many filters show before "More filters"
ppt_search_rail_fieldsFfieldsThe filters in the filter panel
ppt_search_map_pointsFpinsChange the map pins
ppt_ads_between_afterFnumberShow an ad after every N results
ppt_maps_providerF'osm'Use 'osm', 'google' or 'mapbox' maps

Members and accounts​

HookReceivesUse it to
ppt_login_redirectFURL, userWhere members go after signing in
ppt_signup_done_redirectFURL, user IDWhere new members go after signing up
ppt_signup_stepsFstep keys, profileChange the sign-up steps
ppt_free_email_domainsFdomainsThe free-mail domains blocked when "business emails only" is on
ppt_terms_url / ppt_privacy_urlFURLYour terms and privacy pages
ppt_account_verifiedAuser ID, methodA member finished verifying their account
ppt_account_type_changedAuser ID, new type, old typeA member changed account type
ppt_hub_nav_extendAgroups, tab map, user ID, listingsAdd a group or tab to the member area menu
ppt_hub_extra_panelsFHTML, user ID, listings, default tabReturn the content of your member-area tab
ppt_hub_overview_sideAuser IDAdd a card to the member area overview
ppt_hub_listing_row_actionsAlisting ID, postAdd buttons to each row of "My listings"
ppt_hub_account_rowsAuser ID, iconAdd rows to the Account panel
ppt_author_profile_cover / _meta / _bodyAauthor IDAdd to an author's public profile
ppt_message_sentAsender ID, recipient ID, message ID, new conversationA message was sent
ppt_seller_follow_changedAseller ID, follower ID, followingSomeone followed or unfollowed
ppt_saved_search_addedAuser ID, saved searchA member saved a search
ppt_membership_renewedAorder ID, user ID, plan, new expiryA membership renewed
ppt_membership_cancelledAorder ID, user IDA membership was cancelled
ppt_memberships_urlFURLThe page that lists membership plans

The member-area hooks are used in Adding your own features.

Checkout and payments​

HookReceivesUse it to
ppt_payment_gatewaysFgatewaysRegister a payment gateway (Writing a payment gateway)
ppt_gateway_startFnull, gateway ID, order, return URLSend the buyer to your payment page
ppt_gateway_verifyFnull, gateway ID, order detailsConfirm a payment
ppt_checkout_item_paidAitem, order ID, user IDSomething was paid for
ppt_publish_paid_listingFyes/no, listing ID, order IDPublish a listing straight after payment, or not
ppt_subscription_cancelledAorder ID, listing IDA listing subscription was cancelled
ppt_order_type_labelFlabel, order typeThe name of an order type in the admin
ppt_shipping_providersFprovidersRegister a shipping-rate provider
ppt_shipping_rate_quoteFnull, provider ID, shipmentReturn shipping rates
ppt_booking_createdAbooking ID, listing ID, booker ID, nameA booking was made

Emails and notifications​

HookReceivesUse it to
ppt_email_catalogFtemplatesAdd your own email templates
ppt_email_groupsFgroupsAdd a section to the Emails screen
ppt_email_should_sendFyes/no, template key, recipient, tokensStop a particular email
ppt_email_sentAtemplate key, recipient, tokens, sentAn email was sent
ppt_notificationAuser ID, type, title, URL, textAn on-site notification was created
ppt_send_smsAphone number, messageFire this to send a text message
ppt_subscriber_addedAemail, name, source, IDSomeone joined the newsletter
HookReceivesUse it to
ppt_after_announceAPrint something under the announcement bar
ppt_header_actionsAAdd to the header's buttons area
ppt_header_cta_text / ppt_header_cta_urlFtext / URLChange the header's main button
ppt_brand_nameFnameThe site name shown in the header
ppt_footer_linksFlinksThe footer's links
ppt_build_menu_itemFmenu itemChange a menu item as it is built
ppt_page_slugsFslugsThe web addresses of the theme's built-in pages
ppt_blog_title / ppt_blog_subtitleFtextThe blog page's heading
ppt_redirect_destinationsFdestinationsPages offered on the Redirection screen
ppt_enable_analyticsFyes/noTurn the theme's analytics output off
ppt_asset_baseFbase URLServe the theme's files from your own CDN
ppt_countriesFcountriesThe country list
ppt_phone_initial_countryFcountry codeThe default country in phone fields

Blocks and designs​

HookReceivesUse it to
ppt_blocksFblock classesRegister your own homepage blocks (how)
ppt_designsFdesign classesRegister your own full-page designs

Admin​

HookReceivesUse it to
ppt_listing_setup_sectionsAAdd a section to Listings ▸ Setup
ppt_member_edit_cardsAuser ID, memberAdd a card to the admin's member screen
ppt_email_settings_cardsAAdd a card to the email settings
ppt_default_fieldsFfieldsThe 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_cards fires in the Directory Theme's listing editor. Products with their own editor do not fire it yet.
  • ppt_listing_after_title, ppt_listing_after_sections and ppt_single_sidebar_top fire 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_extend and ppt_hub_extra_panels are 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.