Support » Fixing WordPress » Function Missing a Hook?

  • I am using a draft_to_rejected action hook to update some post meta (‘rejected’ is a custom status). Which works fine on the backend when I select rejected from the drop down and hit save. However, I have a following function to update the post status from the frontend, which doesn’t seem to trigger the action

    frontend function:

    function change_post_status($post_id,$status){
        $current_post = get_post( $post_id, 'ARRAY_A' );
        $current_post['post_status'] = $status;
        wp_update_post($current_post);
    }
    
    function show_reject_button(){
        Global $post;
    
            echo '<form name="front_end_reject" method="POST" action="">
                    <input type="hidden" name="pid2" id="pid2" value="'.$post->ID.'">
                    <input type="hidden" name="FE_REJECT" id="FE_REJECT" value="FE_REJECT">
                    <input type="image" src="https://----.com/images/logo1/sreject.png" alt="reject" title="Reject this reservation" style="background: none !important; border: none !important;">
                </form>';
    
    }
    
    if (isset($_POST['FE_REJECT']) && $_POST['FE_REJECT'] == 'FE_REJECT'){
        if (isset($_POST['pid2']) && !empty($_POST['pid2'])){
            change_post_status((int)$_POST['pid2'],'rejected');
        }
    }

    And it is missing this action:

    add_action ('draft_to_rejected', 'void_payment_hold' );

    Does anyone know what hook/action or whatever is not getting hit by using the button to trigger that action?

  • The topic ‘Function Missing a Hook?’ is closed to new replies.