• Resolved jadpm

    (@jadpm)


    Hi there

    I am facing a fatal error while performing some logic in a plugin of mine. The test scenario is quite simple.

    • Include a callback to the before_delete_post action, that will be feeded with the post ID.
    • Inside the callback, gather the post meta with whatever key, and expect it to return the right data according to core documentation.
    • Create a donation with the plugin and then delete it.
    add_action( 'before_delete_post', 'before_delete_post_callback' );
    function before_delete_post_callback( $post_id ) {
      $meta = get_post_meta( $post_id, 'foobar' );
      if ( count( $meta ) > 0 ) {
        ...
      }
    }

    According to the documentation on get_pòst_meta, it should return an array as long as the post ID matches an existing post and the third, optional parameter, is not passed as true. However, when the hook is fired while deleting a donation, the function is returning another thing, but not an array.

    Checking the plugin, it seems that Give_DB_Meta::get_meta might be returning a string regardless the value of the $single parameter when the flag for raw_result is true.

    I am not sure if it is a good idea to modify the expected output of a core function, even if you restrict it to just using it on your own object types.

    Hope that you can find a solution to this problem.

    Regards.

Viewing 1 replies (of 1 total)
  • Plugin Support Matheus Martins

    (@matheusfd)

    Hi, @jadpm.

    We’ve got a spot where you can ask this question directly to our development team, but the question will need to be more fleshed out there than it is here. I’d recommend passing along the exact code snippet you are attempting to use and what results from that snippet. The more focused the question is, the more likely our development team will be able to step away from their busy schedules to help with this sort of custom code.

    You can reach out to them here https://github.com/impress-org/givewp/discussions.

    Thanks for using GiveWP! Have a great day.

Viewing 1 replies (of 1 total)
  • The topic ‘Fatal error when gathering meta on post deletion’ is closed to new replies.