Jump to content

Function ModuleName_ChangePassword not execute anything.


Bets

Recommended Posts

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

Link to comment
Share on other sites

Hey steven, you tell about the field? He are here...

 

imagem_2021-08-04_234444.png

 

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 by Bets
Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 . 

 

 

 

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