Jump to content

Sub-Account access to Custom Pages?


yabdab

Recommended Posts

OK, I have created several custom pages in my WHMCS install.

 

Now that I have finally upgraded to 4.2, I want to establish sub-account access/permissions to my custom created pages.

 

Is this possible? If so, what are the steps needed to set this up?

 

I am asking this on the forums so all can benefit from the answer. :-)

Link to comment
Share on other sites

If you put {debug} into your template you will see the contact permissions array like this

{$contactpermissions}

Array (11)

0
=> profile

1
=> contacts

2
=> products

3
=> manageproducts

4
=> domains

5
=> managedomains

6
=> invoices

7
=> tickets

8
=> affiliates

9
=> emails

10
=> orders

You can use it in your template like this

{if in_array('invoices',$contactpermissions)}

....

{/if}

For that example the contents inside of the if statement will only display if the word "invoices" is in the contactpermissions array.
Link to comment
Share on other sites

Add *this to the clientareaaddcontact.tpl file so users can add your custom page to the contactpermissions.

 


<input type="checkbox" name="permissions[]" id="custompage" value="custompage"{if in_array('custompage',$permissions)} checked{/if} /> <label for="custompage">Custom Page</label><br />

 

*this is obviously a sample. You will need to replace custompage with your unique identifiers.

Link to comment
Share on other sites

Add *this to the clientareaaddcontact.tpl file so users can add your custom page to the contactpermissions.

 


<input type="checkbox" name="permissions[]" id="custompage" value="custompage"{if in_array('custompage',$permissions)} checked{/if} /> <label for="custompage">Custom Page</label><br />

*this is obviously a sample. You will need to replace custompage with your unique identifiers.

This won't add your custom page to the $contactpermissions array in whmcs.

You would need to create a hook to append the custom page name to the array before the page is displayed.

Link to comment
Share on other sites

This won't add your custom page to the $contactpermissions array in whmcs.

You would need to create a hook to append the custom page name to the array before the page is displayed.

 

Not true. ;)

 

WHMCS will add the new custom value to the permissions array and save it to the database that way. It will also be included in the $contactpermissions array that is available on ALL pages (even custom ones)

 

Just make sure the name of the checkbox matches the default ones using permissions[]

 

Here is what you would use at the top of your custom page template(s)...

 

{if $loggedin}

{if !in_array('custompage',$contactpermissions)}
{include file="../templates/default/contactaccessdenied.tpl"}
{else}

{* your custom content *}

{/if}

{/if}

 

You may also want to modify the contactaccessdenied.tpl as well. Your custom page WILL NOT be in the $allowedpermissions array.

 

So change this...

 

<ul>
{foreach from=$allowedpermissions item=permission}
<li>{$permission}</li>
{/foreach}
</ul>

 

to this ....

 

<ul id="permissions">
{foreach from=$contactpermissions item=permission}
{* default *}
{if $permission eq 'profile'}<li>Modify Master Account Profile</li>
{elseif $permission eq 'contacts'}<li>View & Manage Contacts</li>
{elseif $permission eq 'products'}<li>View Products & Services</li>
{elseif $permission eq 'manageproducts'}<li>View & Modify Product Passwords</li>
{elseif $permission eq 'domains'}<li>View Domains</li>
{elseif $permission eq 'managedomains'}<li>Manage Domain Settings</li>
{elseif $permission eq 'invoices'}<li>View & Pay Invoices</li>
{elseif $permission eq 'tickets'}<li>View & Open Support Tickets</li>
{elseif $permission eq 'affiliates'}<li>View & Manage Affiliate Account</li>
{elseif $permission eq 'emails'}<li>View Emails</li>
{elseif $permission eq 'orders'}<li>Place New Orders/Upgrades/Cancellations</li>
{* custom *}
{elseif $permission eq 'custompage1'}<li>Custom Page 1</li>
{elseif $permission eq 'custompage2'}<li>Custom Page 2</li>
{elseif $permission eq 'custompage3'}<li>Custom Page 3</li>
{/if}
{/foreach}
</ul>

 

I hope this helps someone else out :)

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