0

i have two websites, websiteA is a worpdress website, and websiteB is a simple php website. i want to link the two website. i have a form in websiteB and i want it to be able to add users in websiteA. i already tried the code below , it creates user but redirect to websiteA while i am in websiteB:

<form name="myForm" action="http://ipSiteA/wp-admin/user-new.php" method="post">

<input type="hidden" name="action" value="createuser">
<input type="hidden" name="user_login" value="test">
<input type="hidden" name="email" value="mail@gmail.Com">
<input type="hidden" name="pass1" value="test">
<input type="hidden" name="pass2" value="test">
<input type="hidden" name="role" value="seller">
<input type="hidden" name="createuser" value="Ajouter un utilisateur">
<input type="hidden" name="_wpnonce_create-user" value="815389c6d9">
<input type="hidden" name="_wp_http_referer" value="/wp-admin/user-new.php">
<input type="submit" name="create" value="Creer">

is there any other solution using remote apli for example? if not, is there a way to not be redirected to websiteA? thanks

hanane
  • 64
  • 1
  • 9

1 Answers1

0

You can set up a hook on the registration method on the site, where you need it. Open your functions.php in your websiteB. This is in your theme directory. If there is no file like this, create one.

Put this into that file:

add_action('register_form', 'my_register_form');
function my_register_form() {
    //Redirects the user to an URL
    header("Location: http://example.com/");
    die();
}

Of course, you need to write your URL instead of the example.com.

Here is the referenc of the register_form action.

vaso123
  • 12,347
  • 4
  • 34
  • 64
  • but websiteB is not a wordpress site, have i to put your code in websiteB? – hanane Aug 17 '15 at 11:34
  • You want to register your user into the wordpress site right? – vaso123 Aug 17 '15 at 13:00
  • Ok, so the solution above is correct. You need to put this snippet of code, in your wordpress site. ipSiteA. And `header("Location: http://ipSiteB/");` – vaso123 Aug 18 '15 at 14:27