简体   繁体   中英

Signup in two different wordpress at the same time

I Have two wordpress website with many users in it. but now i don't want that a user signup in both of them individually. Please can someone help me to connect the same signup form to both wordpress website. Thank You.

you have two ways to do that.

1. use an ajax call to the second wordpress website and post all data to there by ajax and register user

note : you have to enable Cross Origin resource sharing on your server.

2. use a core wordpress function called wp_safe_remote_post or wp_remote_post .

here is an example of action to be added

add_action('user_register','custom_user_register_new_site',10,1);

function custom_user_register_new_site($user_id){
    $url = 'http://www.example.com/wp-login.php?action=register';
    wp_safe_remote_post($url, ['body'=>$_POST]); // also you can create your own body data as array to be sent. I am sending all data.
}

please let me know if it works or not. (code not tested on real website.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM