Jump to content

Add custom button to admin client service area


weba

Recommended Posts

Hi,

I want to do something simple but I only find complex solutions, must be looking in the wrong direction 😉

I want to add a button to the admin clientservice page. And when button is pressed I want to execute a custom function on that selected service.

Is there some sample code for this ?

Help would be appriciated!

Michel.

 

Link to comment
Share on other sites

Hi Michel,

4 hours ago, weba said:

I want to do something simple but I only find complex solutions, must be looking in the wrong direction 😉

I suspect there wouldn't be a "simple" solution for this... you would likely have to use a hook to inject JS into the page.. which I assume are the complex solutions that you've already seen.

Link to comment
Share on other sites

A button in the same area as the Create, suspend, update stats, etc?   Have you looked at _AdminCustomButtonArray() function as described in https://developers.whmcs.com/provisioning-modules/custom-functions/ ?   So for example:

function mymodule_AdminCustomButtonArray() 
{
    $buttonarray = array(
	 "Cool Action" => "CoolFuntion",
	);
	return $buttonarray;
}

function mymodule_CoolFuntion($params) 
{
	// Do some really awesome sauce stuff
    if (1 + 1 = 5)
       return "success"; //math is awesome
    else
       return "Error:  Math is still right, space time has not been warped"; 
}

Just remember when returning the button array, it calls for the function name minus the module prefix bits and the return has to be success or error message. 

Above presumes you can change the module's code and such of course.   If you can't, then yeah javascript, hooks, etc are your route.

Or am I missing something? 

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