scribu / wp-posts-to-posts

Efficient many-to-many connections between posts, pages, custom post types, users.
http://wordpress.org/plugins/posts-to-posts/
975 stars 261 forks source link

Payment_complete not working with p2p #508

Open prodes opened 9 years ago

prodes commented 9 years ago

Hi,

I want to get all connected posts during a woocommerce_payment_complete but I keep getting this message: 'Call to a member function get_connected() on boolean' or 'Can't determine direction for 'multiple_authors' type'. It seems like the payment_complete fires before the p2p_init hook.

Does anyone have any solutions for this?

dchichizola commented 7 years ago

$connected = $wpdb->get_var( $wpdb->prepare( " SELECT p2p_from FROM $wpdb->p2p WHERE p2p_type=%s AND p2p_to=%d ", 'your_connection_type', $post_id ) );