Jump to content

I want to overwrite parameters using 'PreModuleCreate' hook


Suganuma

Recommended Posts

I'm sorry, my English is not good.

I want to rewrite password.
I wrote the following source.
But can not overwrite.
Hook is working.

-------------------------------------------------------------------
add_hook('PreModuleCreate', 1, function($vars)
    {
    $characters = '!@#$%^&*?_~';
    $ch_length = strlen($characters) - 1;
    $n = rand(0, $ch_length);

    $vars['params']['password'] .= $characters[$n];

    return $vars;

    }
);
-------------------------------------------------------------------
The following was not good either.

-------------------------------------------------------------------
add_hook('PreModuleCreate', 1, function($vars)
    {
    $characters = '!@#$%^&*?_~';
    $ch_length = strlen($characters) - 1;
    $n = rand(0, $ch_length);

    $vars['params']['password'] .= $characters[$n];
    $newpw = $vars['params']['password'];

    return array(
                'password' => $newpw,
            );

    }
);
-------------------------------------------------------------------

Password remains unchanged.


 

Link to comment
Share on other sites

steven99, thank you very much for your answer

Changed $vars['params']['password'] to $vars['password']
But can not overwrite.

-------------------------------------------------------------------
add_hook('PreModuleCreate', 1, function($vars)
    {
    $characters = '!@#$%^&*?_~';
    $ch_length = strlen($characters) - 1;
    $n = rand(0, $ch_length);

    $vars['password'] .= $characters[$n];

    return $vars;

    }
);
-------------------------------------------------------------------

Is "Provisioning Modules" required?
I do not use it

Or do I need to write directly to the table?
 

Link to comment
Share on other sites

Yes, a server module of some kind would be needed for that hook to fire.  For example, you could use the sample server module to take get all the functions, then simply remove everything in the functions and return "success" .   Also, server /provisioning modules don't really need to be attached to a server for them to be able to work. 

Could  you provide more detail on your setup? 

Link to comment
Share on other sites

I asked questions without telling my setup.
Please forgive me.

WHMCS version 7.6.1
PHP Version 7.2.14
CentOS Linux 7.5.1804
nginx 1.14.2-centos7.19022720
I do not use add-on modules

Please let me know if you have other necessary information.

Also,i tried "OverrideModuleUsernameGeneration" hook and saw it.
It is possible to rewrite the username with "OverrideModuleUsernameGeneration" hook.
    --------------------------------------------------------------------------------------
    add_hook('OverrideModuleUsernameGeneration', 1, function ($vars) {

        $newusername = 'test0000';
        $vars['username'] = $newusername;

       return $vars['username'];
    });
    --------------------------------------------------------------------------------------
 

Link to comment
Share on other sites

The 'OverrideModuleUsernameGeneration' hook is not required.
However, I could rewrite 'username' using 'OverrideModuleUsernameGeneration' hook.
I want to rewrite 'password' in the same way, but I do not know the difference from 'PreModuleCreate'.
I'm reading 'Developer Documentation' but I'm not sure.

I am very sorry for my lack of knowledge and my poor English.
I'm glad if 'OverrideModulePasswordGeneration' exists.

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