Jump to content

Client Area Custom Functions when service is suspended


grassroots

Recommended Posts

Hi,

Is it possible to allow a custom function to be processed from the client area product details pages even when the service is suspended?  I have a product that is set to auto terminate after 30 days.  I have used hooks to abort the terminate and instead suspend the service.  This works fine.

Now I would like to add a button to the product details pages that says something like "Extend Trial - 1 Day".  This would allow them to reactivate the account, try for one more day, and also reactivate the ability to upgrade the account.

However, if I create a custom function in my module, and add a button to the product details page I get the following when clicked - Action Failed Product must be active to perform this action

Is there a way to allow this function to run even when the service is suspended?

 

Thanks,
Grassroots!

 

Link to comment
Share on other sites

Nope. I asked WHMCS in a ticket, because I wanted to allow things like "resubmit domain transfer" when the domain is in "Pending Transfer" status. No such luck. They said to createa  feature request at requests.whmcs.com ... but we all know it's going to get buried there as non-techy WHMCS users want their frivolous features that any dev could implement without WHMCS's help.

Link to comment
Share on other sites

When there a will, there's always a way!!!

 

I would attack the scenario with a different approach, if WHMCS if not letting use the default function since the product is disabled/suspended, then have your function modify directly the status of the product in the WHMCS database.

 

EX :

// Function called when button is press
function module_Extend_Trial(array $param) {

  // Update WHMCS Product status
  Capsule::table('tblhosting')
    ->where('id', $params['serviceid'])
    ->where('userid', $params['userid'])
    ->update(['domainstatus' => 'Active']);

  // Call the function to Extend one more day
  module_Do_Extend_Trial($params);

}


// Function to do really cool stuff
function module_Do_Extend_Trial(array $params) {

	// Extend Trial code

}
Link to comment
Share on other sites

5 hours ago, Neutrall said:

When there a will, there's always a way!!!

 

I would attack the scenario with a different approach, if WHMCS if not letting use the default function since the product is disabled/suspended, then have your function modify directly the status of the product in the WHMCS database.

 

EX :


// Function called when button is press
function module_Extend_Trial(array $param) {

  // Update WHMCS Product status
  Capsule::table('tblhosting')
    ->where('id', $params['serviceid'])
    ->where('userid', $params['userid'])
    ->update(['domainstatus' => 'Active']);

  // Call the function to Extend one more day
  module_Do_Extend_Trial($params);

}


// Function to do really cool stuff
function module_Do_Extend_Trial(array $params) {

	// Extend Trial code

}

That does not work.  As mentioned, any custom functions in a module fail if the service is suspended.  None of the code in the function is executed.  This would need to be run somewhere else outside of the module itself.  This is basically exactly what I said above, which does not work.

I am thinking I will create a button which submits to an external (but secure) php file.  This file will use the external API to change the product status, etc.. and then redirect the client to the upgrade page.

Link to comment
Share on other sites

5 hours ago, Neutrall said:

When there a will, there's always a way!!!

 

I would attack the scenario with a different approach, if WHMCS if not letting use the default function since the product is disabled/suspended, then have your function modify directly the status of the product in the WHMCS database.

 

EX :


// Function called when button is press
function module_Extend_Trial(array $param) {

  // Update WHMCS Product status
  Capsule::table('tblhosting')
    ->where('id', $params['serviceid'])
    ->where('userid', $params['userid'])
    ->update(['domainstatus' => 'Active']);

  // Call the function to Extend one more day
  module_Do_Extend_Trial($params);

}


// Function to do really cool stuff
function module_Do_Extend_Trial(array $params) {

	// Extend Trial code

}

Also, that would probably not be a very good way of changing the status.  Why make direct modifications to the DB when you can use the Internal API to do it much cleaner and safer.  Additionally. by modifying the DB like that, the module UnSuspend functions are not run and the product remains suspended on the server.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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