admin管理员组文章数量:1387398
I have a form that redirects to a payment platform and sends data in $_POST.
<form method="POST" action=".pl" accept-charset="UTF8" id="knp-form" target="_top">
<table border="0" cellpadding="2" cellspacing="0" width="20%">
<meta charset="UTF-8">
<tr>
<td width="50%">Nom:</td>
<td width="50%"><input type="text" name="NOM" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Prenom:</td>
<td width="50%"><input type="text" name="PRENOM" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Adresse:</td>
<td width="50%"><input type="text" name="ADRESSE" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Code Postal:</td>
<td width="50%"><input type="text" name="CODEPOSTAL" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Ville:</td>
<td width="50%"><input type="text" name="VILLE" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Pays:</td>
<td width="50%"><select size="1" name="PAYS">
<option value="CH" selected="selected">Suisse </option>
<option value="FR">France</option>
</select>
</td>
</tr>
<tr>
<td width="50%">Tel:</font></td>
<td width="50%"><input type="text" name="TEL" size="24" value=""></td>
</tr>
<tr>
<td width="50%">E-mail:</font></td>
<td width="50%"><input type="text" name="EMAIL" size="24" value=""></td>
</tr>
<input type="hidden" name="ID" value="1234567890">
<input type="hidden" name="ABONNEMENT" value="123ABC465DEF7890">
<tr>
<td width="100%" colspan="2">
<p align="center"><input type="submit" value="Envoyer" name="B1"></p></td>
</tr>
</table>
I wanted to create an action like a user registration but unfortunately the action doesn't seem to work.
The user is redirected to the payment platform without the user being created on WP.
function traitement_formulaire_inscription() {
if (isset($_POST['B1'])) {
$user_login = sanitize_text_field( $_POST['EMAIL'] );
$user_email = sanitize_email( $_POST['EMAIL'] );
$user = register_new_user( $user_login, $user_email );
}
}
add_action('template_redirect', 'traitement_formulaire_inscription', 5);
I have a form that redirects to a payment platform and sends data in $_POST.
<form method="POST" action="https://www.paiementgateway/paiement/order1.pl" accept-charset="UTF8" id="knp-form" target="_top">
<table border="0" cellpadding="2" cellspacing="0" width="20%">
<meta charset="UTF-8">
<tr>
<td width="50%">Nom:</td>
<td width="50%"><input type="text" name="NOM" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Prenom:</td>
<td width="50%"><input type="text" name="PRENOM" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Adresse:</td>
<td width="50%"><input type="text" name="ADRESSE" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Code Postal:</td>
<td width="50%"><input type="text" name="CODEPOSTAL" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Ville:</td>
<td width="50%"><input type="text" name="VILLE" size="24" value=""></td>
</tr>
<tr>
<td width="50%">Pays:</td>
<td width="50%"><select size="1" name="PAYS">
<option value="CH" selected="selected">Suisse </option>
<option value="FR">France</option>
</select>
</td>
</tr>
<tr>
<td width="50%">Tel:</font></td>
<td width="50%"><input type="text" name="TEL" size="24" value=""></td>
</tr>
<tr>
<td width="50%">E-mail:</font></td>
<td width="50%"><input type="text" name="EMAIL" size="24" value=""></td>
</tr>
<input type="hidden" name="ID" value="1234567890">
<input type="hidden" name="ABONNEMENT" value="123ABC465DEF7890">
<tr>
<td width="100%" colspan="2">
<p align="center"><input type="submit" value="Envoyer" name="B1"></p></td>
</tr>
</table>
I wanted to create an action like a user registration but unfortunately the action doesn't seem to work.
The user is redirected to the payment platform without the user being created on WP.
function traitement_formulaire_inscription() {
if (isset($_POST['B1'])) {
$user_login = sanitize_text_field( $_POST['EMAIL'] );
$user_email = sanitize_email( $_POST['EMAIL'] );
$user = register_new_user( $user_login, $user_email );
}
}
add_action('template_redirect', 'traitement_formulaire_inscription', 5);
Share
Improve this question
asked Apr 15, 2020 at 17:41
KamdurasKamduras
11 bronze badge
2 Answers
Reset to default 0That's because you're using a post action which sends the user to another website. The template_redirect never runs because the user isn't on your site any more. You'll need to keep them on the site, register the new user then send them to the gateway with the post data.
I found the solution.
I removed the action in form
<form method="POST" action="" accept-charset="UTF8" id="knp-form" target="_top">
And now the action hook with wp_redirect with 307 code.
function traitement_formulaire_inscription() {
if (isset($_POST['B1'])) {
$user_login = sanitize_text_field( $_POST['EMAIL'] );
$user_email = sanitize_email( $_POST['EMAIL'] );
$user = register_new_user( $user_login, $user_email );
wp_redirect( 'https://www.paiementgateway/paiement/order1.pl?', 307 );
exit;
}
}
add_action('template_redirect', 'traitement_formulaire_inscription', 5);
本文标签: redirectMake a treatment before the action of the form
版权声明:本文标题:redirect - Make a treatment before the action of the form 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744559560a2612688.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论