Jump to content

Hooks - Hide menu for a specific product.


Recommended Posts

Can you help me create the hooks to hide this part of the menu?

Portal Home / Client Area / My Products & Services / Product Details

This part of the menu should only be hidden  if the product is = "Plano Site para Igreja"

image.jpeg.c66979b8ecfd27df2f7c02012cdc852b.jpeg

I'm not sure how to create it, I've never done it before.

Link to comment
Share on other sites

  • WHMCS Developer

There are a number of ways that you could achieve this.

One of the ways this could be accomplished is with the ClientAreaProductDetails and ClientAreaPrimarySidebar hook points. You would be using the ClientAreaProductDetails hook point to get the Package ID, and then nest the ClientAreaPrimarySidebar hook point inside that to modify the sidebar.

Information about these two hook points can be found at the following URLs:

https://developers.whmcs.com/hooks-reference/client-area-interface/#clientareaproductdetails
https://developers.whmcs.com/hooks-reference/client-area-interface/#clientareaprimarysidebar

The ClientAreaProductDetails hook point returns the Service class which you can read more about at https://docs.whmcs.com/classes/7.1/WHMCS/Service/Service.html

I have taken a moment to put together a basic example of such a hook. You can review this below:

<?php
$data['packages'] = array('1'); // Array of Package IDs to be affected
$data['children'] = array('Login to cPanel', 'Login to Webmail', 'Change Password'); // Array of Children to be removed

add_hook('ClientAreaProductDetails', 1, function ($vars) use ($data) {
    $packageId = $vars['service']->packageId;
    if (in_array($packageId, $data['packages'])) {
        add_hook('ClientAreaPrimarySidebar', 1, function ($primarySidebar) use ($data) {          
            $targetSidebar = $primarySidebar->getChild('Service Details Actions');
            if ($targetSidebar) {
                foreach ($data['children'] as $child) {
                    $targetSidebar->removeChild($child);
                }
            }
        });
    }
});

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated