MyBB Community Forums

Full Version: Weird MyBB error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I'm trying to update the users PW from my plugin.

This is the code:

// Generate Password
			$p_Password = random_str(15);
			
			require_once './inc/datahandlers/user.php';
			$userhandler = new UserDataHandler("update");

			$p_user = array(
			"uid" => $p_UID,
			"password" => $p_Password,
			"password2" => $p_Password
			);
			
			$userhandler->set_data($p_user);

			$errors = '';

			if(!$userhandler->validate_user())
			{
				$errors = $userhandler->get_friendly_errors();
			}
			
			$userhandler->update_user();

The error I get:
Fatal error: Call to undefined function generate_salt() in C:\xampp\htdocs\inc\datahandlers\user.php on line 219

The strange thing is that the insert part (creating user) works fine, so why doesnt this pw update?
Any ideas guyes?

Thanks!
Require inc/functions_user.php

require MYBB_ROOT.'inc/functions_user.php';
// your code
(2016-05-26, 09:49 PM)nth Wrote: [ -> ]Require inc/functions_user.php

require MYBB_ROOT.'inc/functions_user.php';
// your code

Thanks mate!
That worked, may I ask why I have to include that for update but not for insert?
(2016-05-26, 10:05 PM)BearMan Wrote: [ -> ]
(2016-05-26, 09:49 PM)nth Wrote: [ -> ]Require inc/functions_user.php

require MYBB_ROOT.'inc/functions_user.php';
// your code

Thanks mate!
That worked, may I ask why I have to include that for update but not for insert?

Because it's a function defined in functions_user.php, it's not a method for the class.