Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda