redirect to /wp-admin/edit.php instead of wp_redirect url

Question

I´m trying for a custom post type to make changes on the admin edit post page by a link with params.
The problem is when I´m trying to redirect to the page without these custom params thanks wp_redirect().

This is my code in a class:

    add_action('admin_init',array( $this, 'foo_actions' ) );

    function  foo_actions(){
         if( isset( $_GET['foo_action'] ) ){
                // ob_clean();
                // ob_start();
                $order_id = (int) $_GET['post'];
                switch ( $_GET['foo_action'] ) {
                    case ACTION_RENEW_PLAN :
                        Orders::renew_plan($order_id);
                        break;
                    case ACTION_UNRENEW_PLAN :
                        Orders::unrenew_plan($order_id);
                        break;
                    case ACTION_ENABLE_AUTO_PLAN_RENEWED :
                        Orders::enable_auto_plan_renewed($order_id);
                        break;
                    case ACTION_DISABLE_AUTO_PLAN_RENEWED :
                        Orders::disable_auto_plan_renewed($order_id);
                        break;
                } 
                $edit_post_link = get_edit_post_link($order_id);
                wp_redirect( $edit_post_link );
                exit();
         }
    }

This code redirect to /wp-admin/edit.php instead of $edit_post_link.
How can I fix this ?

0
J.BizMai 2 years 2020-12-30T09:10:26-05:00 0 Answers 2 views 0

Leave an answer

Browse
Browse