• Resolved Shillongtitude

    (@shillongtitude)


    Hello,

    I tried to use the example code from the official Jetpack CRM github page here: https://github.com/Automattic/jetpack-crm-code-examples/blob/master/examples/custom-client-portal-page.php to add a custom link to a page. I made a folder in the plugins folder with two files on it, somePluginName.php and test.php with the following content but when I activate the plugin, the item is not added to the portal menu:

    somePluginName.php

    <?php
    /*
    Plugin Name: somePluginName
    Plugin URI: https://example.com
    Description: Adds tab to the Jetpack CRM Client Portal
    Version: 1.0
    Author: Some Author
    */
    
    add_filter('jetpack_crm_portal_endpoints', 'jetpackCRM_clientPortal_yourEndpoint');
    function jetpackCRM_clientPortal_yourEndpoint($allowed_endpoints){
    	$allowed_endpoints[] = 'somePage';
    	return $allowed_endpoints;
    }
    function jetpackCRM_portal_your_endpoint_somePage() {
    	add_rewrite_endpoint( 'somePage', EP_ROOT | EP_PAGES );
    }
    add_action( 'init', 'jetpackCRM_portal_your_endpoint_somePage' );
    
    /* 
    	Here we add a menu item to the client portal tabbed menu
    	* Make sure 'yourendpoint' matches the endpoint specified above, and don't forget to change your menu name!
    	* The "fa-icon" string represents a font-awesome v4 icon: https://fontawesome.com/v4.7.0/icons/
    */
    add_filter('jetpack_crm_portal_nav_menu_items', 'jetpackCRM_clientPortal_yourendpointMenu');
    function jetpackCRM_clientPortal_yourendpointMenu($nav_items){
    	$nav_items['somePage'] = array('name' => 'Some Page', 'icon' => 'fa-icon', 'show' => 1, 'slug' => 'somePage');
    	return $nav_items;
    }
    
    /* 
    	Here's where we actually expose the content:
    */
    add_action('jetpack_crm_portal_yourendpoint_endpoint', 'jetpackCRM_clientPortal_somePage');
    function jetpackCRM_clientPortal_somePage(){
    
    	do_action('zbs_pre_somePage_content');
    	if(!is_user_logged_in()){
    		return zeroBS_get_template('login.php');
    	}else{
    		if (!jetpackCRM_portalIsUserEnabled())
    			return zeroBS_get_template('disabled.php');
    		else
    			return jetpackCRM_clientPortalProCustomerYour_Content();
    	}
    	do_action('zbs_post_somePage_content');
    
    }
    
    /* 
    	This example loads a html file from the plugin directory (same as this file)
    */
    function jetpackCRM_clientPortalProCustomerYour_Content(){
    	$template_file = plugin_dir_path(__FILE__) . "test.php";
    	include $template_file;
    }

    test.php

    <?php
    /**
     * Portal Ticket Page 
     */
    
     
    if ( ! defined( 'ABSPATH' ) ) exit; // Don't allow direct access
    
    do_action( 'zbs_enqueue_scrips_and_styles' );
    
    #} was added through above action too, then re-called directly
    //zeroBS_portal_enqueue_stuff();
    
        $uid = get_current_user_id();
        $uinfo = get_userdata( $uid );
        $cID = zeroBS_getCustomerIDWithEmail($uinfo->user_email);
    ?>
    
    <div id="zbs-main" class="zbs-site-main" style="position:relative;">
    	
    	<div class="zbs-client-portal-wrap main site-main zbs-portal zbs-hentry">
    
    		<?php
    			//moved into func
    			zeroBS_portalnav('dashboard');
    		?>
    		<div class='zbs-portal-wrapper'>
    			<?php zeroBSCRM_portal_adminPreviewMsg($cID); ?>
    			<?php 
    				// admin msg (upsell cpp) (checks perms itself, safe to run)
    				zeroBSCRM_portal_adminMsg();
    
    				$page_title = __("Ticket Section","zero-bs-crm");
    				$page_title = apply_filters('zbs_portal_dashboard_title', $page_title);
    			?>
    		<h1><?php echo $page_title; ?></h1>
    
    		<div class='content' style="position:relative;">
    			<p>
    				<?php
    				//add actions for additional content
    				do_action('zbs_pre_somePage_content');
    
    				$dashboard = __("Welcome to your Client Dashboard. From here you can view your information using the portal navigation bar.", "zero-bs-crm");
    				//added so this can be modified, with a shortcode too 
    				$dashboard = apply_filters('zbs_portal_dashboard_content' , $dashboard);
    				echo $dashboard;
    
    				do_action('zbs_post_somePage_content');
    				?>
    			</p>
    
    		</div>
    
    		</div>
    		<div style="clear:both"></div>
    
    	</div>
    
    	<div style="clear:both"></div>
    
    	<?php zeroBSCRM_portalFooter(); ?>
    
    </div>

    What am I doing wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Shillongtitude

    (@shillongtitude)

    UPDATE:

    I got it working but not sure how to add more than one tab to the portal menu using just this one custom plugin. What would be the right way to go about it?

    Thread Starter Shillongtitude

    (@shillongtitude)

    RESOLVED: The github code works fine. Worked fine after I fixed a few typos in my code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding custom link to page on Portal menu’ is closed to new replies.