From version 2.87+ of Jetpack CRM, the Client Portal is much easier to work with. This articles gives example code for how to add extra tabs to the Portal (and how to add content to those tabs)
Step 1: Add to the Allowed Endpoints
The first step, is to make sure you register your endpoint with the Portal. The following is how you would do that
add_filter('zbs_portal_endpoints', 'zeroBSCRM_clientPortal_yourEndpoint'); function zeroBSCRM_clientPortal_yourEndpoint($allowed_endpoints){ $allowed_endpoints[] = 'yourendpoint'; return $allowed_endpoints; }
This registers your endpoint for the Portal.
Step 2: Register the Endpoint
Secondly, you need to make sure that the endpoint will exist.
function zeroBSCRM_portal_your_endpoint_slug() { add_rewrite_endpoint( 'yourendpoint', EP_ROOT | EP_PAGES ); } add_action( 'init', 'zeroBSCRM_portal_your_endpoint_slug' );
Step 3: Add to the Navigation Menu
Next, you need to register your endpoint to the admin actions.
add_filter('zbs_portal_nav_menu_items', 'zeroBSCRM_clientPortal_yourendpointMenu'); function zeroBSCRM_clientPortal_yourendpointMenu($nav_items){ $nav_items['yourendpoint'] = array('name' => 'Nav Menu Name', 'icon' => 'fa-icon', 'show' => 1, 'slug' => 'yourendpoint'); return $nav_items; }
This adds a navigation link to the Portal, with yourendpoint as the slug.
Step 4: Add your Content
Finally, you want to have content for your endpoint. The following example also includes support for the contact needing to be logged in, and shows portal disabled, if they have Portal access disabled
add_action('zbs_portal_yourendpoint_endpoint', 'zeroBSCRM_clientPortal_yourendpoint'); function zeroBSCRM_clientPortal_yourendpoint(){ //add actions for additional content do_action('zbs_pre_yourendpoint_content'); if(!is_user_logged_in()){ return zeroBS_get_template('login.php'); }else{ if (!zeroBSCRM_portalIsUserEnabled()) return zeroBS_get_template('disabled.php'); else return zeroBSCRM_clientPortalProCustomerYour_Content(); } do_action('zbs_post_yourendpoint_content'); }
The function zeroBSCRM_clientPortalProCustomerYour_Content()
will output your content for the tab. The following is an example.
function zeroBSCRM_clientPortalProCustomerYour_Content(){ $template_file = plugin_dir_path(__FILE__) . "portal/files.php"; include $template_file; }
You can view example content in any of the includes templates in the /portal/templates/ folder of Jetpack CRM. Make sure to copy the full template and edit as appropriate.