I have a login system and only logged in users can access this form. I use php as back end (Wordpress API). I am trying to add the email from the logged in user to an endpoint as you can see. Now it's hardcoded. The problem is that after submitting the form, the page is simply reloading and it don't submit the form with the action attribute.
I tried to hardcode the string (without appending it) and it's working. Also the action attribute is added if I do not submit the form (I can see it inspecting the element). What is the problem and why the form is not being submited with the action attribute added before?
jQuery code:
$('#firebase-checkout4').submit(function(event){
event.preventDefault();
$('#firebase-checkout4').attr('action', '/wp-json/api/checkout4/dxds@ds.commm');
//$('#firebase-checkout4').submit();
return true;
});
PHP code:
public static function firebase_checkout4_func() {
$html = "";
$html .= "<form id='firebase-checkout4' method='POST'>
<button type='submit' id='checkout-button'>Începe acum</button>
</form>";
return $html;
}