I am (for the first time) developing a WordPress-plugin which is a simple registration-form. It sends the data to an API. At settings page you can chose to which page the user should be redirected to after the submit is successful. But the redirect is not working.
I am getting the link for the page like this:
$options = get_option('rfw_options');
$successPage = (isset($options['rfw_field_success_page']) ? esc_html($options['rfw_field_success_page']) : 'Select Page');
// some code for API call
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status == 200) { // that means if successful
$successLink = get_permalink(get_page_by_title($successPage));
header("Location: '. $successLink .'");
}
Even if I set the header location like following its not working:
header("Location: https://www.google.no/");
Here you can see how I do set up my form:
function rfw_html_form_code() {
echo '<form action="' . esc_url($_SERVER['REQUEST_URI']) . '" method="post">';
echo '<div class="flex-container"><p>';
_e('Fornavn (obligatorisk)', 'recman-form-widget');
echo '<br><input type="text" name="rfw-fname" pattern="[A-Za-z\wåäöæéøâèêóòôÅÄÖÆÉØÂÈÊÓÒÔ]+" value="' . $_POST['rfw-fname'] . '" required />';
echo '</p>';
echo '<p>';
_e('Etternavn (obligatorisk)', 'recman-form-widget');
echo ' <br /><input type="text" name="rfw-lname" pattern="[A-Za-z\wåäöæéøâèêóòôÅÄÖÆÉØÂÈÊÓÒÔ]+" value="' . $_POST['rfw-lname'] . '" required />';
echo '</p></div>';
}
I hope somebody can help me to solve this issue.