Bets Posted August 4, 2021 Share Posted August 4, 2021 Hi, We are making a custom server module, all works perfectly, but this function specific i cant make it work. What we are doing wrong? function moduleName_ChangePassword($params) { return 'call this function'; } Making a simple test, just to return this text a error, when we click on the "Change Password" button, dont happens anything, no messages show. Just we scrolled up. Thank you 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted August 5, 2021 Share Posted August 5, 2021 Make sure your template still has the change password forms on it as it sounds like those were removed. 0 Quote Link to comment Share on other sites More sharing options...
Bets Posted August 5, 2021 Author Share Posted August 5, 2021 (edited) Hey steven, you tell about the field? He are here... Im telling about the server module. Not a theme template. Using the provisioning module as a reference. Basically this function does not perform clicking the change password button: https://github.com/WHMCS/sample-provisioning-module/blob/3abdf8bacf99327eda0d33451959bfe1c173fd78/modules/servers/provisioningmodule/provisioningmodule.php#L304-L332 Edited August 5, 2021 by Bets 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted August 5, 2021 Share Posted August 5, 2021 That screenshot is for the admin, not the the client area that the ChangePassword() is for . When ChangePassword() is in the module, a button in the secondary nav in the client area -> product details page shows. Clicking that button brings up a form. This form is within the clientareaproductdetails.tpl template file at line 463 within a bootstrap tab. If that has been removed or those tabs changed to not work, then it would cause the behavior you are seeing and thus I will refer back to my initial post. 0 Quote Link to comment Share on other sites More sharing options...
Bets Posted August 5, 2021 Author Share Posted August 5, 2021 Steven, I not refer to customer area, i me refer to the admin. Im making a server module, not a theme template. 0 Quote Link to comment Share on other sites More sharing options...
string Posted August 5, 2021 Share Posted August 5, 2021 I also recently noticed that in WHMCS 8.2, there is no longer an error message when there is a problem changing passwords. However, a log entry is created in the WHMCS activity log. Since the function name "modulename_ChangePassword" is correct, I see no reason why the function should not be executed. I don't know of any bug in the current WHMCS version that would prevent the execution. I think you just see the same missing return message as i have seen, i suggest to check the WHMCS activity log. Also, to determine if your function is being executed, you can use "logActivity ('text')" instead of return. When executed, an entry is created in the WHMCS activity log. However, that should anyway be the case when you return something else than success. 0 Quote Link to comment Share on other sites More sharing options...
Bets Posted August 5, 2021 Author Share Posted August 5, 2021 8 minutes ago, string said: I also recently noticed that in WHMCS 8.2, there is no longer an error message when there is a problem changing passwords. However, a log entry is created in the WHMCS activity log. Since the function name "modulename_ChangePassword" is correct, I see no reason why the function should not be executed. I don't know of any bug in the current WHMCS version that would prevent the execution. I think you just see the same missing return message as i have seen, i suggest to check the WHMCS activity log. Also, to determine if your function is being executed, you can use "logActivity ('text')" instead of return. When executed, an entry is created in the WHMCS activity log. However, that should anyway be the case when you return something else than success. Thank you String, "logActivity " helped a lot. The function are working properly, the password got changed. But it is normal, not return any success or error message? The complete function: function moduleName_ChangePassword($params) { $hostname = 'xxxxxxxx'; $token = "XXXXXXXXX"; $cPanelUrl = "https://".$hostname.":2087/json-api/passwd?api.version=1&user=".$params['username']."&password=".$params['password']; $cPanelApi = curl_init(); curl_setopt_array ( $cPanelApi, array ( CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array ( "Authorization: whm root:".$token ), CURLOPT_URL => $cPanelUrl )); $result = curl_exec($cPanelApi); $data = json_decode($result, true); if ($data['metadata']['result'] > 0) { logActivity('Change password worked', 0); return 'success'; } else { logActivity('Error: '.$data['metadata']['reason'], 0); return 'Error: '.$data['metadata']['reason']; } } It's not a big deal, it's very simple. 0 Quote Link to comment Share on other sites More sharing options...
string Posted August 5, 2021 Share Posted August 5, 2021 6 minutes ago, Bets said: But it is normal, not return any success or error message? I think it is a WHMCS bug. I have noticed the same behavior in WHMCS 8.2. It may also occur in previous versions, but it should not be intended that way. As far as I remember, in WHMCS 7.x the error message is returned as expected. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted August 5, 2021 Share Posted August 5, 2021 41 minutes ago, Bets said: Steven, I not refer to customer area, i me refer to the admin. Im making a server module, not a theme template. I understand now but your initial post stated when you hit "Change password" the pages scrolled up and thus lead me down the template route thinking you were hitting the Change password nav button and not the submit button. If you had said no results message shows at the client or admin pages, then that would have lead down a different route. At this point if the logactivity is showing the success entry, then it is WHMCS being WHMCS . 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted August 5, 2021 Share Posted August 5, 2021 24 minutes ago, string said: [...] It may also occur in previous versions, [..] Just did a server module using changepassword and it returns the result as expected. No surprise it is a password related bug in WHMCS. 😉 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.