RESOLVED
Bootstrap mode doesn’t liked to be called within a PHP5 Class
Hi, i have the same problem, im using a simple application i wrote in OOP and i need to create users to wp via wp_create_user (to syncronize my app users with wp).
Did you find a solution?
require_once('../wp-blog-header.php');
require('../wp-includes/registration.php');
$random_password = wp_generate_password( 12, false );
$user_details = array(
'ID' => '',
'user_pass' => $random_password,
'user_login' => $ccustemail,
'user_email' => $ccustemail,
'first_name' => $ccustfirstname,
'last_name' => $ccustlastname,
'user_registered' => $ctranstime,
'role' => 'subscriber'
);
$user_id = wp_insert_user($user_details);
The wp_insert_user() function is used within the PHP5 Class, the require files are above the PHP5 class
My code looks like the one you posted, but is within my php class and after the first include i got redirected to ./wp-admin/install.php
I was wondering if you found out a solution to do that inside a class..
I can not require wp bootstrap before initialize my class, becose some plugin my customer is using interfere to some path I use returning 404.
After some research, i found this other way:
[inside my class]
public function do_something_wp($data)
{
include(MYWP_PATH . 'wp-settings.php');
$wp->initialize();
wp_insert_user($data['user'], $data['passwd'], $data['email']);
}
but i get the same result of the previous bootstrap.
I wonder why this happens just while using a class…