Hi Nigel,
I have updated the plugins but am now dealing with a more pressing issue as a result (see thread at https://toolset.com/forums/topic/cred-login-page-display-issue-after-upgrade-to-latest-plugins/)
I will update you as soon as I have been able to properly test the 500 error issue.
Hi Nigel,
Now the other issues are resolved have been able to properly test the code and can confirm it works correctly.
For reference...
The CRON Job Code to bring existing posts up to date: https://toolset.com/forums/topic/copy-post-taxonomy-value-to-another-taxonomy-on-cred-save/#post-1090231
The CRED Form Code to perform the same action for all new posts...
// Manage Voyage Country Taxonomies
add_action('cred_save_data', 'cred_save_voyage_countries', 10, 2);
function cred_save_voyage_countries($post_id, $form_data) {
$forms = [ 90, 110 ];
if ( in_array( $form_data['id'], $forms ) )
{
error_log("starting...");
$embarkationcountry = wp_get_post_terms($post_id, 'embarkation-country');
$disembarkationcountry = wp_get_post_terms($post_id, 'disembarkation-country');
error_log(print_r($embarkationcountry, true)); //should be array of term objects
error_log(print_r($disembarkationcountry, true)); //should be array of term objects
if ( !empty( $embarkationcountry ) ){
$emb_term_list = wp_get_post_terms($post_id, 'embarkation-country', array("fields" => "all"));
$emb_term_slug = $emb_term_list[0]->slug;
$country_slug_emb = get_term_by('slug', $emb_term_slug, 'countries');
$country_id_emb = $country_slug_emb->term_id;
error_log(print_r($emb_term_list, true));
error_log(print_r($emb_term_slug, true));
error_log(print_r($country_slug_emb, true));
error_log(print_r($country_id_emb, true));
}
if ( !empty( $disembarkationcountry ) ){
$dis_term_list = wp_get_post_terms($post_id, 'disembarkation-country', array("fields" => "all"));
$dis_term_slug = $dis_term_list[0]->slug;
$country_slug_dis = get_term_by('slug', $dis_term_slug, 'countries');
$country_id_dis = $country_slug_dis->term_id;
error_log(print_r($dis_term_list, true));
error_log(print_r($dis_term_slug, true));
error_log(print_r($country_slug_dis, true));
error_log(print_r($country_id_dis, true));
}
error_log(print_r($country_id_emb, true));
error_log(print_r($country_id_dis, true));
$termsarray = array( $country_id_emb, $country_id_dis );
error_log(print_r($termsarray, true));
wp_set_post_terms($post_id, $termsarray, 'countries');
}
}