1

I have a page (custom_post_type_A) with a form (from plugin wp user frontend, create custom_post_type_B) in this page.

When (in frontend) user insert value in the form i want an action wordpress for CONNECT (with Posts2Posts plugin) CPT_A with CPT_B.

I use in my functions.php:

function my_connection_collette_types() {
p2p_register_connection_type( array(
    'name' => 'CPT_A_to_CPT_B',
    'from' => 'CPT_A',
    'to' => 'CPT_B'
) );
}
add_action( 'p2p_init', 'my_connection_collette_types' );

This work in backend of wordpress.

Now, i want, after user submit form, create action hook for programmatically connect 2 post.

function connect_cpt_A_cpt_B($post_id) {
$id_CPT_A=$post_id;
$id_CPT_B=??????????
p2p_type( 'my_connection_collette_types' )->connect( $id_CPT_A, $id_CPT_B, array('date' => current_time('mysql')) );
}
add_action( 'wpuf_add_post_after_insert', 'connect_cpt_A_cpt_B' );

In this function i know $id_CPT_A (is $post_id value), but, i dont know $id_CPT_B. This value is the $post-id of the main page where i have the form. How i can retrieve and transmite this value to function?

0

OK, i resolved this:

simply $id_CPT_B is $_POST['page_id'].

Thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.