Hello all 🙂
I am using 2
Custom Taxonomy Multiselector
xprofile fields to pass the values (selected categories and selected tags) from a CPT into a new post with the use ofwp_insert_post
.I have 2 taxonomies
event_tag
andevent_category
from the CPT.`
$post_cat_data = (array) xprofile_get_field_data( ‘EVENT CATEGORIES’ ,$user_id );
$post_tag_data = (array) xprofile_get_field_data( ‘EVENT TAGS’ ,$user_id );$args = array(
//more args…
‘post_type’ => ‘event’,
‘tax_input’ => array(
‘event_category’ => $post_cat_data,
‘event_tag’ => $post_tag_data,
),
);$ID = wp_insert_post( $args );
`
$post_tag_data
are passing correct totax_input
but$post_cat_data
are not.
I have tried also$post_cat_data = xprofile_get_field_data( 'EVENT CATEGORIES' ,$user_id, 'array' );
but it didn’t work. Any ideas would be appreciated.The results that i am getting from the the 2 fields with var_dump are:
for EVENT CATEGORIES
<pre>array(2) { [0]=> string(164) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Walk</a></li></ul>" [1]=> string(152) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Dance</a></li></ul>" } </pre>
for EVENT TAGS
<pre>array(3) { [0]=> string(128) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Speak</a></li></ul>" [1]=> string(144) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Read</a></li></ul>" [2]=> string(128) "<ul class="bpxcftr-multi-taxonomy-terms-list"><li><a href="">Think</a></li></ul>" } </pre>
So the results looks the same.
Hi,
You are accessing the formatted value for display.Please use the raw value using
$values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field_id, $user_id ) );
Regards
Brajesh
You must be logged in to reply to this topic.