• My code is like below.

    $result = $wpdb->query($sql);
        if ( $result ) {
          wp_redirect( "https://www.example.com/contact-us");
          exit();
        }

    I am getting below error

    Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wordpressplugin/wp-admin/includes/misc.php:1281) in /var/www/html/wordpressplugin/wp-includes/pluggable.php on line 1296

    I tried with below code but I didn’t get any solution

    $result = $wpdb->query($sql);
        if ( $result ) {
          ob_start();
          wp_redirect( "https://www.example.com/contact-us");
          ob_end_flush();
          exit();
        }
    • This topic was modified 4 years, 3 months ago by abufoysal.
    • This topic was modified 4 years, 3 months ago by bcworkz. Reason: code fixed
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_redirect() is not working’ is closed to new replies.