yabdab Posted May 29, 2010 Share Posted May 29, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
xeqution Posted May 31, 2010 Share Posted May 31, 2010 I would also be interested in this, I have several custom pages. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted May 31, 2010 Share Posted May 31, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
yabdab Posted May 31, 2010 Author Share Posted May 31, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
xeqution Posted June 1, 2010 Share Posted June 1, 2010 Thanks Sparky & yabdab! very much appreciated! 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted June 1, 2010 Share Posted June 1, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
yabdab Posted June 1, 2010 Author Share Posted June 1, 2010 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.