Open tcarterfrance opened 7 years ago
Hi, great plugin, thanks,
When I do : $p2p_id = p2p_type( 'posts_to_infos' )->connect( $post_id, $info_to_add, array( 'featured' => $featured, 'reply' => $reply, 'minimum' => $minimum, 'maximum' => $maximum, ) );
I get the featured and reply metas twice in table PREFIX_p2pmeta, one with default value one with correct value.
Work-a-round :
$p2p_id = p2p_type( 'posts_to_infos' )->connect( $post_id, $info_to_add, array() ); p2p_update_meta( $p2p_id, 'featured', $featured ); p2p_update_meta( $p2p_id, 'reply', $reply ); p2p_update_meta( $p2p_id, 'minimum', $minimum ); p2p_update_meta( $p2p_id, 'maximum', $maximum );
My connection functions are :
function ci_connection_types() {
... p2p_register_connection_type( array( 'name' => 'posts_to_infos', 'from' => 'post', 'to' => 'infos', 'admin_box' => array( 'show' => 'any', 'context' => 'advanced', ), 'fields' => array( 'featured' => array( 'title' => 'Phare', 'type' => 'select', 'values' => array( 'Phare','Pas phare' ), 'default_cb' => 'ci_info_feature_status', ), 'reply' => array( 'title' => 'Reponse', 'type' => 'text', 'default_cb' => 'ci_info_excerpt', ), 'minimum' => array( 'title' => 'Minimum', 'type' => 'text', ), 'maximum' => array( 'title' => 'Maximum', 'type' => 'text', ), ), ) );
} add_action( 'p2p_init', 'ci_connection_types' );
function ci_info_feature_status( $connection, $direction ) { global $post;
$key = ( 'from' == $direction ) ? 'p2p_to' : 'p2p_from'; $post = get_post( $connection->$key ); setup_postdata( $post ); $featured_info = get_post_meta($post->ID, 'featured_info', true ); $status = ($featured_info == 'featured_info') ? 'Phare' : 'Pas phare'; return $status;
}
Hi, great plugin, thanks,
When I do : $p2p_id = p2p_type( 'posts_to_infos' )->connect( $post_id, $info_to_add, array( 'featured' => $featured, 'reply' => $reply, 'minimum' => $minimum, 'maximum' => $maximum, ) );
I get the featured and reply metas twice in table PREFIX_p2pmeta, one with default value one with correct value.
Work-a-round :
$p2p_id = p2p_type( 'posts_to_infos' )->connect( $post_id, $info_to_add, array() );
p2p_update_meta( $p2p_id, 'featured', $featured ); p2p_update_meta( $p2p_id, 'reply', $reply ); p2p_update_meta( $p2p_id, 'minimum', $minimum ); p2p_update_meta( $p2p_id, 'maximum', $maximum );
My connection functions are :
function ci_connection_types() {
} add_action( 'p2p_init', 'ci_connection_types' );
function ci_info_feature_status( $connection, $direction ) { global $post;
}