Skip to content

Hooks: Actions and Filters ​

Extend Smart Team Pro with code. This page has ready-to-use recipes, then a reference of every action and filter the plugin provides.

Smart Team Pro has hooks: places in its code where WordPress lets your own code step in. There are two kinds:

  • A filter hands you a value (a label, an icon, a piece of HTML). You change it and hand it back.
  • An action lets you run your own code, or print extra output, at a set point.

To use any snippet on this page, add it to your theme's functions.php file. Use a child theme, so a theme update doesn't wipe out your changes, or a code-snippets plugin.

For developers

This page assumes you're comfortable editing PHP. A mistake in functions.php can take your site down, so test on a staging site first and keep a backup.

Blocks or classic?

Smart Team Pro renders teams in two ways, and most hooks only work in one of them:

  • Block layouts (Grid, Carousel, 3D Carousel and the member field blocks) have their own small set of hooks. See Block rendering.
  • Classic teams (the [wpteam id="…"] shortcode from Manage Teams) and the plugin's built-in single member template use the older member-field hooks.

Each recipe says which one it applies to.

Classic teams cache their output

Classic teams save rendered member fields in a cache. If a snippet doesn't seem to work on a classic team, go to Smart Team Pro → Settings → Performance and click Flush Cache.

Jump to a recipe:

  1. Give Editors access to the plugin
  2. Add a company name after the job title
  3. Run shortcodes in the member description
  4. Use a custom overlay icon on member images
  5. Set a custom placeholder image
  6. Set the placeholder image size
  7. Use a custom email (or other contact) icon
  8. Change the member name heading tag
  9. Remove a classic team's dynamic CSS
  10. Show only the current language in ajax results (WPML)
  11. Add a class to every Grid block
  12. Run code when a block renders
  13. Turn off Ready Patterns or the AI Team Builder
  14. Override a classic template

Recipes ​

1. Give Editors access to the plugin ​

Applies to: the whole plugin.

By default, only Administrators can manage Smart Team Pro. To let Editors in too, return a capability Editors have (like edit_others_pages) from sp_wp_team_pro_ui_permission. The Departments, Designations and other taxonomy screens use their own filter, sp_wp_team_free_ui_permission, so set both:

php
function my_sptp_editor_access() {
	return 'edit_others_pages';
}
add_filter( 'sp_wp_team_pro_ui_permission', 'my_sptp_editor_access' );
add_filter( 'sp_wp_team_free_ui_permission', 'my_sptp_editor_access' );

2. Add a company name after the job title ​

Applies to: classic teams and the built-in single member template.

The sp_team_pro_after_member_job_title action runs right after each member's job title, so anything you print there appears below it:

php
function my_sptp_member_company_name() {
	echo '<h4 class="sptp-member-company">' . esc_html__( 'Acme Inc.', 'my-theme' ) . '</h4>';
}
add_action( 'sp_team_pro_after_member_job_title', 'my_sptp_member_company_name' );

Every member gets the same text. There's a matching sp_team_pro_before_… / sp_team_pro_after_… action pair for each member field. See Member field actions.

3. Run shortcodes in the member description ​

Applies to: classic teams.

By default, a shortcode typed into a member's description shows as plain text on classic teams. Run the description through do_shortcode() with the sptp_member_description filter:

php
function my_sptp_description_shortcodes( $description ) {
	return do_shortcode( $description );
}
add_filter( 'sptp_member_description', 'my_sptp_description_shortcodes' );

4. Use a custom overlay icon on member images ​

Applies to: classic teams.

When a classic team shows an icon over the member photo on hover, sptp_member_image_overlay_icon controls its markup. This swaps it for a Font Awesome 4 "play" icon:

php
function my_sptp_overlay_icon() {
	return '<i class="fa fa-play"></i>';
}
add_filter( 'sptp_member_image_overlay_icon', 'my_sptp_overlay_icon' );

5. Set a custom placeholder image ​

Applies to: classic teams.

Members without a photo get a grey placeholder image. To use your own, upload it to the Media Library, copy its File URL, and return that URL from sptp_member_placeholder_image_src:

php
function my_sptp_placeholder_image() {
	return 'https://example.com/wp-content/uploads/team-placeholder.png';
}
add_filter( 'sptp_member_placeholder_image_src', 'my_sptp_placeholder_image' );

Prefer an attachment ID? Return it from sptp_member_placeholder_image_id instead. The image is then treated like a real member photo and uses the team's image size settings.

6. Set the placeholder image size ​

Applies to: classic teams.

A placeholder from a URL (recipe 5) is shown at 600 × 450 pixels by default. Change that with sptp_placeholder_image_width and sptp_placeholder_image_height:

php
function my_sptp_placeholder_width() {
	return 300; // In pixels.
}
add_filter( 'sptp_placeholder_image_width', 'my_sptp_placeholder_width' );

function my_sptp_placeholder_height() {
	return 300; // In pixels.
}
add_filter( 'sptp_placeholder_image_height', 'my_sptp_placeholder_height' );

If the team's image size is set to a custom width and height, those values win over these filters.

7. Use a custom email (or other contact) icon ​

Applies to: block layouts and classic teams.

Each contact detail on a member card has an icon filter named sp_team_pro_member_{field}_icon. This one replaces the email icon:

php
function my_sptp_email_icon() {
	return '<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" aria-hidden="true"><path d="M2 4h20v16H2z M2 4l10 8 10-8"/></svg>';
}
add_filter( 'sp_team_pro_member_email_icon', 'my_sptp_email_icon' );

Swap email for phone, mobile, location, website or experience. Block layouts also support language and gender.

A few things to know:

  • Use an <i> tag or an inline <svg>. Block layouts strip any other markup (like <img>) from the icon.
  • Font Awesome isn't always loaded for blocks. Font Awesome 4 classes like fa fa-envelope-open work on classic teams. On block layouts the font may not be loaded, so an inline SVG is safer.
  • Classic quirk: on classic teams, the experience row also uses the email icon filter, so changing the email icon changes the experience icon too.

8. Change the member name heading tag ​

Applies to: classic teams and the built-in single member template.

Member names are h2 headings by default. To use a different tag, for example h1 on the single member page, filter sptp_team_pro_member_name_tag:

php
function my_sptp_member_name_tag() {
	return 'h1';
}
add_filter( 'sptp_team_pro_member_name_tag', 'my_sptp_member_name_tag' );

This changes the tag everywhere the classic name template is used. On a block-built member page, use the Member Name block's HTML Tag setting instead. See Field Blocks.

9. Remove a classic team's dynamic CSS ​

Applies to: classic teams.

Each classic team prints CSS built from its settings (colors, spacing, typography). If you'd rather write all the styling yourself, return an empty string from sp_team_pro_dynamic_css:

php
add_filter( 'sp_team_pro_dynamic_css', '__return_empty_string' );

This removes the CSS that's printed next to the team. When a page has been visited before, Smart Team Pro moves that CSS into the page <head> instead, and this filter doesn't reach it there. To clear that copy too, add:

php
function my_sptp_remove_head_css() {
	wp_styles()->add_data( 'wp-team-pro', 'after', array() );
}
add_action( 'wp_enqueue_scripts', 'my_sptp_remove_head_css', 20 );

Both snippets also remove the responsive breakpoint CSS and anything in Settings → Additional CSS & JS, so the team will look unstyled until you add your own CSS.

10. Show only the current language in ajax results (WPML) ​

Applies to: classic teams.

When a classic team loads more members or runs a live search over ajax, Smart Team Pro skips WordPress's query filters. With WPML, that can show members from every language. If it happens on your site, let the language filter run:

php
add_filter( 'sptp_suppress_filters', '__return_false', 20 );

The priority of 20 matters, because the plugin sets this value itself at the default priority. For the full multilingual setup, see Translations.

11. Add a class to every Grid block ​

Applies to: block layouts.

sptp_block_render_attributes gives you a block's settings just before it renders, so you can change them site-wide. This adds a CSS class to every Grid block:

php
function my_sptp_grid_class( $attributes, $block_name ) {
	if ( 'grid' === $block_name ) {
		$existing                         = isset( $attributes['additionalCssClass'] ) ? $attributes['additionalCssClass'] : '';
		$attributes['additionalCssClass'] = trim( $existing . ' my-team-grid' );
	}
	return $attributes;
}
add_filter( 'sptp_block_render_attributes', 'my_sptp_grid_class', 10, 2 );

$block_name is the block's short name without the sptp/ prefix: grid, carousel, carousel-3d, member-name and so on.

12. Run code when a block renders ​

Applies to: block layouts.

sptp_before_render and sptp_after_render run around every Smart Team block. They suit side jobs like loading an extra stylesheet only on pages that have a carousel:

php
function my_sptp_carousel_styles( $block_name ) {
	if ( 'carousel' === $block_name ) {
		wp_enqueue_style( 'my-team-carousel', get_stylesheet_directory_uri() . '/team-carousel.css', array(), '1.0' );
	}
}
add_action( 'sptp_before_render', 'my_sptp_carousel_styles' );

Don't echo from these actions. The block's HTML is returned, not printed, so anything you echo lands in the wrong place on the page.

13. Turn off Ready Patterns or the AI Team Builder ​

Applies to: the block editor.

To remove these features in code, for example on a client site, whatever the dashboard says:

php
// Turn off the Ready Patterns library (editor modal and its REST routes).
add_filter( 'sptp_ready_patterns_enabled', '__return_false' );

// Turn off the AI Team Builder.
add_filter( 'sptp_ai_builder_enabled', '__return_false' );

See Patterns Library and AI Team Builder.

14. Override a classic template ​

Applies to: classic teams, the classic member pop-up and the built-in single member template.

Classic teams are built from small PHP template files you can override from your theme, without editing the plugin:

  1. Find the template in the plugin's src/Frontend/templates/ folder, for example member/name.php.
  2. In your child theme, create a wp-team-pro/templates/ folder.
  3. Copy the file in, keeping its subfolder: your-child-theme/wp-team-pro/templates/member/name.php.
  4. Edit your copy. Smart Team Pro uses it instead of its own.

Overridable files include the layouts (grid.php, carousel.php, list.php, table.php, accordion.php, org-chart.php …), each member field under member/ (name.php, job_title.php, email.php, social.php …), the pop-up (sptp-modal.php) and the single member page (sptp-single.php plus the layouts in member/member-templates/).

WARNING

Your copy won't receive fixes from future plugin updates. Override only the files you need, and compare them with the plugin's versions after major updates. Block layouts don't use these templates.

Hook reference ​

Every action and filter Smart Team Pro provides, grouped by area. Defaults are shown in the arguments column.

Block rendering ​

HookTypeArgumentsWhat it does
sptp_block_attributesfilter$attributes, $block_nameChanges a block's registered attribute definitions (types and defaults) when it registers.
sptp_block_render_attributesfilter$attributes, $block_nameChanges a block's saved settings just before it renders. Example.
sptp_before_renderaction$block_name, $attributes, $content, $blockRuns before any Smart Team block renders. Example.
sptp_after_renderaction$block_name, $attributes, $output, $blockRuns after a block renders, with its HTML (read-only).
sp_team_pro_member_{field}_iconfilter$icon_markup, $icon_setIcon before a contact detail on block cards. {field}: email, phone, mobile, location, website, experience, language, gender. Example.
sptp_block_template_authorfilter$label ('Smart Team')Author name shown for the plugin's member template in the Site Editor.

Member details & single page ​

HookTypeArgumentsWhat it does
sptp_use_plugin_single_templatefilter$use_plugin, $postWhether the plugin's own single member template renders the member page (instead of a block template).
sptp_modal_load_by_rest_apifilter$loadWhether classic member pop-ups load their content on demand. Overrides Settings → Performance → Load Modal by Rest API.
the_content_sptpfilter$contentMember description in the classic pop-up, before shortcodes run.
sp_team_pdf_btn_labelfilter$label ('Download PDF File')Label of the PDF download button on the built-in single member page.
sptp_team_pro_member_name_tagfilter$tag ('h2')Heading tag for member names. Example.

Member fields, classic output filters ​

These filters receive the finished HTML of one member field on classic teams and the built-in single page. Return changed HTML.

HookWhat it filters
sptp_member_nameMember name
sptp_member_job_titleJob title
sptp_member_email · sptp_member_phone · sptp_member_mobileEmail, phone and mobile rows
sptp_member_location · sptp_member_website · sptp_member_experienceLocation, website and experience rows
sptp_member_skillSkill bars
sptp_member_socialSocial profile icons
sptp_member_extra_fieldsCustom (extra) fields
sptp_member_imageMember photo
sptp_member_descriptionRendered description. Example.
sptp_member_contentDescription text before it's cleaned and wrapped in paragraphs
sptp_read_moreRead More link
sptp_hire_buttonHire button
sptp_author_postMember's author posts list

More member filters (classic):

HookArgumentsWhat it does
sptp_allowed_tags$allowed_tagsHTML tags allowed in member descriptions. Add a tag here (for example iframe) to stop it being stripped.
sptp_member_image_overlay_icon$iconIcon shown over member photos on hover. Example.
sptp_member_placeholder_image_id$attachment_id ('')Media Library image used when a member has no photo.
sptp_member_placeholder_image_src$urlPlaceholder image URL. Example.
sptp_placeholder_image_width · sptp_placeholder_image_height$px (600 / 450)Placeholder image size. Example.
sp_team_pro_member_{field}_icon$iconContact icons on classic cards (email, phone, mobile, location, website). Example.

Member field actions ​

Classic teams fire a before/after pair around each member field. Echo whatever you want to appear there.

Action pairField
sp_team_pro_before_member_name / sp_team_pro_after_member_nameName
sp_team_pro_before_member_job_title / sp_team_pro_after_member_job_titleJob title. Example.
sp_team_pro_before_member_description / sp_team_pro_after_member_descriptionDescription
sp_team_pro_before_member_email / sp_team_pro_after_member_emailEmail
sp_team_pro_before_member_mobile / sp_team_pro_after_member_mobileMobile
sp_team_pro_before_member_phone / sp_team_pro_after_member_phonePhone
sp_team_pro_before_member_experience / sp_team_pro_after_member_experienceExperience
sp_team_pro_before_member_location / sp_team_pro_after_member_locationLocation
sp_team_pro_before_member_website / sp_team_pro_after_member_websiteWebsite
sp_team_pro_before_member_extra_fields / sp_team_pro_after_member_extra_fieldsCustom fields
sp_team_pro_before_member_skill / sp_team_pro_after_member_skillSkills
sp_team_pro_before_member_social / sp_team_pro_after_member_socialSocial profiles
sp_team_pro_before_section_title / sp_team_pro_after_section_titleThe team's section title

Classic team display ​

HookTypeArgumentsWhat it does
sptp_preloaderfilter$htmlPreloader markup.
sptp_section_title_textfilter$titleTeam section title text.
sptp_section-titlefilter$htmlRendered section title.
sptp_search_placeholder_textfilter$text ('Search Member')Placeholder in the live search box.
sp_team_p_end_of_members_textfilter$textMessage shown when Load More / infinite scroll runs out of members.
sptp_custom_link_targetfilter$target ('_blank')Link target for member custom links and single page links set to open in a new tab.
sp_wp_team_pro_call_to_action_btn_targetfilter$target ('_blank')Link target of the call-to-action button.
sptp_group_filter_sort · sptp_position_filter_sort · sptp_location_filter_sortfilter$terms, $team_idTerms (and their order) in the live filter for Departments, Designations and Locations.
sptp_suppress_filtersfilter$suppressWhether member queries skip WordPress query filters. Example.
sp_team_pro_dynamic_cssfilter$cssCSS printed next to a team. Example.
sp_team_pro_add_custom_cssactionnoneLegacy. Fires while a team's CSS is built; prefer Settings → Additional CSS & JS.
spteam_pro_transient_expirationfilter$secondsHow long classic teams cache member data. Overrides Settings → Performance → Cache Time.
team_pro_style_load_in_headerfilter$boolDeprecated, no effect. Kept so old snippets don't error.

Patterns & AI ​

HookTypeArgumentsWhat it does
sptp_ready_patterns_enabledfilter$enabled (true)Turns the Ready Patterns library on or off. Example.
sptp_patterns_remote_urlfilter$urlURL of the pattern list the library loads. Return '' to stop remote fetching.
sptp_patterns_single_remote_urlfilter$url (''), $pattern_id, $manifest_urlURL for a single pattern's content.
sptp_ai_builder_enabledfilter$enabled (true)Turns the AI Team Builder on or off. Example.
sptp_ai_pattern_first_enabledfilter$enabled (true)Whether the AI builder may answer a prompt with a matching Ready Pattern. false always generates settings instead.
sptp_ai_generate_rate_limitfilter$limit (20), $user_idAI requests each user may make per 10 minutes. 0 turns off the limit.

Admin & permissions ​

HookTypeArgumentsWhat it does
sp_wp_team_pro_ui_permissionfilter$capability ('manage_options')Capability needed to use the plugin's admin screens and dashboard. Example.
sp_wp_team_free_ui_permissionfilter$capability ('manage_options')Capability needed to see the taxonomy screens (Departments, Designations…).
sptp_member_exclude_from_searchfilter$excludeWhether members are left out of WordPress search. Overrides Settings → Advanced Controls → Exclude from Search.
sp_team_pro_menu_positionfilter$position (80)Position of the Smart Team Pro menu in the admin sidebar.
sptp_dashboard_all_block_listfilter$groupsThe block list on the dashboard's Blocks page.
sp_wp_team_pro_shortcode_importedaction$new_team_idRuns after each classic team is imported through Settings → Tools.
sptp_wpml_suppress_filtersfilter$suppress (1)Whether classic team export ignores WPML's language filter.
sp_wp_team_home_urlfilter$urlSite URL sent when activating the license (single sites).
wp_team_pro_is_local_serverfilter$is_localWhether the site counts as a local server. It no longer skips the license check.
spf_field_typography_safewebfontsfilter$fontsSafe web fonts in the classic Typography picker and the Single Page typography settings.
spf_field_typography_googlestylesfilter$stylesFont weights/styles offered for Google Fonts in the same pickers.
spf_field_typography_customwebfonts · spf_field_typography_googlewebfonts · spf_field_typography_webfonts · spf_field_typography_defaultstyles · spf_field_typography_backup_font_familyfilterlistFont lists in the classic Typography picker. Custom fonts must already be loaded by your theme.

Taxonomy visibility ​

Departments, Designations, Locations, Languages and Genders are private by default. They group members in the admin, but don't have public archive pages. Return true to make one public, then re-save Settings → Permalinks:

HookTaxonomy
sp_wp_team_free_group_publicDepartments (sptp_group)
sp_wp_team_free_designation_publicDesignations (sptp_designation)
sp_wp_team_free_location_publicLocations (sptp_location)
sp_wp_team_free_language_publicLanguages (sptp_language)
sp_wp_team_free_gender_publicGenders (sptp_gender)
php
add_filter( 'sp_wp_team_free_group_public', '__return_true' );

The older sp_wp_team_pro_group_public filter still exists, but a later registration replaces its Department setting. Use sp_wp_team_free_group_public instead.