I'm trying in the WP boilerplate in the public area to redirect after form submittion. But i'm getting a error.
Cannot modify header information - headers already sent by (output started at
public\partials\filename.php:
public function redirect_to_dashboard($value) {
if ( isset( $_POST) ) {
$redirect = get_permalink( $value );
wp_redirect($redirect);
exit;
}}
I calling the function with a valid permalink (same file public\partials\filename.php):
redirect_to_dashboard($escape_room_data->id)
I also added in the includes\filename-plugin.php the add_action
$this->loader->add_action( 'wp-loaded', $plugin_public, 'redirect_to_dashboard' );
Calling
global $wpdb;
if (!empty($_POST)) {
$code = $_POST['code'];
$like = "'%" . $wpdb->esc_like( $code ) . "%'";
$result = $wpdb->get_row($wpdb->prepare("SELECT * FROM wp_teptickets WHERE code = %s", $wpdb->esc_like($code)));
if (!empty($result)) {
if ($result->used == false) {
$table_name = $wpdb->prefix . "teptickets";
$wpdb->update( $table_name, array(
'used' => '1'
), array(
'id' => $result->id
) );
} else {
echo 'code already used';
$escape_room_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM wp_tepescapes WHERE id = %s", $wpdb->esc_like($result->escape_room)));
redirect_to_dashboard($escape_room_data->id);
}
} else {
print_r('code not valid');
}}
Thank for helping!