Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

278
Visualizações
WordPress DO i need an exit() after redirecting a url

I have a gateway plugin and I added the code below to redirect the customer to a custom page when the payment fails.

My question is, do I need to add exit(); after the end of the redirect_url which is inside the if statement?

I have seen some codes with exit and some without.

else {
        //failed
        $this->msg['class'] = 'error';
        $this->msg['message'] = __( "Your Transaction Has Failed Due to Some Technical Error. Please Try Again.<br/><br/>", 'toBeTranslatd');
        $order->update_status('failed');
        $order->add_order_note('Failed');
        $order->add_order_note($this->msg['message']);
        $redirect_url = home_url( '/payment-faild/' );

        $lang_code = get_post_meta( $order_id, 'wpml_language', true );
        if ( $lang_code === ar ) {
            $redirect_url = apply_filters( 'wpml_permalink', $redirect_url, $lang_code );
            //exit(); // Do I need this or delete it?
        }
}
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Wordpress provides two functions for this:

  • wp_redirectDoc

and

  • wp_safe_redirectDoc

And here's what wordpress recommends:

Note: wp_redirect() and wp_safe_redirect() do not exit automatically, and should almost always be followed by a call to exit;

over 4 years ago · Santiago Trujillo Relatório

0

wp_redirect() or wp_safe_redirect() does not exit or die automatically, and should almost always be followed by a call to exit or die();

Reference : https://developer.wordpress.org/reference/functions/wp_redirect

Thank you.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda