How to use Multisite WordPress functions in a different Single WordPress
-
I have two setup – Single WP & Multisite WP Network
I want to use the multisite’s wpmu_create_user function on the one custom file which is located on the root of single wp setup. I have tried below code but it throws Error establishing a database connection.
<?php
$wp_load_loc = “/opt/lampp/htdocs/mulsite/wp-load.php”;
require_once($wp_load_loc);
echo $wpdb->prefix;
$user = wpmu_create_user(‘[email protected]’, ‘123456’, ‘[email protected]’);
add_user_to_blog( 1, $newuser, ‘subscriber’ );
add_user_to_blog( 2, $newuser, ‘subscriber’ );
echo ‘Userid-‘ . $user;
?>I have also tried including ms-settings.php and ms-load.php but doesn’t work.
After a lot of debugging, I have checked to include another single wp’s wp-load.php and it works (Below code)! So the issue seems to the multisite configuration which defined in the wp-config file.
<?php
ob_start();
$wp_load_loc = “/opt/lampp/htdocs/singlewp/wp-load.php”;
require_once($wp_load_loc);
echo $wpdb->prefix;
?>I have spent many hours on such an issue. Kindly look into and please suggest the solution as soon as possible.
Thanks in advance!
The topic ‘How to use Multisite WordPress functions in a different Single WordPress’ is closed to new replies.