Developers – Hooks & Filters

You are here:
Read time: 1 min

We include several custom filters that will allow you to modify the output on the front end without ever modifying the plugin itself.  If you are not familiar with WordPress filters and what they are, more information about filters can be found on the WordPress Codex.

The Custom Filter Hooks are as follows:

Specific Page Content Filters

wcp_all_leads_filter – The Home page content (all contacts)
wcp_events_filter – The Calendar view
wcp_logging_filter – The Logging Page
wcp_stats_filter – The Statistics Page
wcp_ie_filter – The Import and Export Page
wcp_individual_filter – The Individual View Page
wcp_sst_fields_filter – The Source Types and Status Page
wcp_edit_fields_filter – The Edit Fields Page
wcp_front_sort_filter – The Front Page Sorting Page
wcp_leads_filter – The Front Page Leads Array, containing all lead fields output on the front page

Page Section Filters

wcp_head_section_filter  – Head Section and Side menu
wcp_menu_links_filter – Side menu contents
wcp_bottom_section_filter – Bottom of page content (footer)


What this means to you is as a developer is that you can modify the output of any of these pages and sections before it’s output by creating your own functions to customize what’s displayed – and when there is a plugin update, you’ll still have your modifications because they won’t be in the plugin!

For theme developers and those who just want to make customizations you can add these functions right in your theme’s functions.php file (or anywhere else that makes sense).  Below are a couple of very simple examples to get you started in your own customizations.

 

<?php
/* Simply adding a header to the head output right after it */
function modify_wcp_head( $html ) {
    return $html . '<h2>Test Adding to Head section</h2>';
}
add_filter( 'wcp_head_section_filter', 'modify_wcp_head');

/* Add another link, or something else to the side menu */
function modify_menu_links( $html ) {
    return $html . '<li class="eventslink"><a href="#">New Link at the bottom <i class="wcp-md md-event-available"></i></a></li>';
}
add_filter( 'wcp_menu_links_filter', 'modify_menu_links');

/* Add your own content before the output on the default front page view */
function modify_all_leads( $html ) {
    return '<p>Hi There</p>' . $html;
}
add_filter( 'wcp_all_leads_filter', 'modify_all_leads');

If you would like to see us add other hooks to WP Contacts, send us a message through our support and let us know about it!

Was this article helpful?
Dislike 0
Views: 108
Previous: Rest Hooks
Next: Translation
Join Our Mailing List!