Suganuma Posted March 22, 2019 Share Posted March 22, 2019 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. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted March 22, 2019 Share Posted March 22, 2019 Should just be: $vars['password'] and not $vars['params']['password'] . 0 Quote Link to comment Share on other sites More sharing options...
Suganuma Posted March 25, 2019 Author Share Posted March 25, 2019 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? 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted March 25, 2019 Share Posted March 25, 2019 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? 0 Quote Link to comment Share on other sites More sharing options...
Suganuma Posted March 26, 2019 Author Share Posted March 26, 2019 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']; }); -------------------------------------------------------------------------------------- 0 Quote Link to comment Share on other sites More sharing options...
Suganuma Posted March 26, 2019 Author Share Posted March 26, 2019 I forgot to write Plesk Onyx Version 17.8.11 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted March 26, 2019 Share Posted March 26, 2019 Both hooks documentation makes me think a provisioning module of some kind is required, but are you saying OverrideModuleUsernameGeneration hook works for your required item? 0 Quote Link to comment Share on other sites More sharing options...
Suganuma Posted March 27, 2019 Author Share Posted March 27, 2019 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. 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.