1. Home
  2. Developers
  3. Extensions
  4. Extending the Client Portal

Extending the Client Portal

From version 2.87+ of Zero BS 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() {
	add_rewrite_endpoint( 'yourendpoint', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'zeroBSCRM_portal_your_endpoint' );

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);
	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 Zero BS CRM

Updated on July 5, 2018

Was this article helpful?

Related Articles

Add A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.