Error when using wp_insert_user within operational_hooks.php

Matthijs

Member
Hi, within operational_hooks.php I would like to create a new wordpress user.

I use this code:

require_once('../wp-load.php');

$userdata = array(
'user_login' => $row2['new_id'],
'user_email' => $row['email'],
'user_pass' => $pass2,
'display_name' => $row2['new_id'],
'role' => 'abonnee'
);
$user = wp_insert_user($userdata);

But then I get this error:
PHP message: PHP Fatal error: Cannot declare class PasswordHash, because the name is already in use in /home/mslboot/domains/mslb.nl/public_html/wp-includes/class-phpass.php on line 44

My question: is there a way to use the Wordpress functions in operational_hooks.php ?

thanks for any help!

Your current DaDaBIK version​

You are using DaDaBIK version 11.10-Elba monthly, installed on 13-07-2023 (installation code: 18828644e443ac0e33), the latest version of DaDaBIK is 11.10-Elba released on 13-07-2023

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 8.1.19

mysql version: 10.6.13-MariaDB

Web server: Apache/2

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82
 
Top