Home › Toolset Professional Support › [Resolved] Create Form Fields Dynamically Based On Term Count
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Related documentation:
This topic contains 19 replies, has 3 voices.
Last updated by Christian Cox 3 years, 10 months ago.
Assisted by: Christian Cox.
Chris,
The good news is that I have been able to create the form as you suggested to thanks a ton for that!
Now my next step is to 1) get the data from the dynamic field and, 2)save it in a custom field on the expert review. That way, I could come back and retrieve the rating given for an expert review at a later date without worrying about storing it anywhere else.
For 1) it is trickier than a thought to get the data from generic fields as the field slug is dynamic so I wrote a conde to make that happen which should work but may be I missing something.
For 2) I want to confirm with you one thing - can I store an array into custom field.
Code below:
add_action('cred_save_data', 'add_rubric_results_to_array',10,2);
function add_rubric_results_to_array($post_id, $form_data) {
$forms = array( 12080, 12090 );
if ( in_array( $form_data['id'], $forms ) )
{
$rating_array = array();
$expert_match_terms = array();
$expert_match_terms_slug = array();
$expert_match_id = $_GET['expert-match-id'];
// $expert_match_id = $toolset_get_related_post($post_id, 'expert-match-id-to-expert-review', 'parent', 'publish');
$expert_match_terms = get_the_terms( $expert_match_id, 'skill-category' );
if ( $expert_match_terms && ! is_wp_error( $expert_match_terms ) ) {
foreach ( $expert_match_terms as $term ) {
// $expert_match_terms_slug[] = $term->slug;
$args = array();
$args = array(
'post_type' => 'criterion',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'skill-category',
'field' => 'slug',
'terms' => $term->slug
)
),
);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
// Do Stuff
$criterion_post = get_post();
$criterion_slug = $criterion_post->post_name;
//create dynamic field slug with format: rating-taxonomyslug-criterionslug
$generic_field = "rating-";
$generic_field .=$term->slug;
$generic_field .="-";
$generic_field .=$criterion_slug;
$generic_field_value = $_POST[$generic_field];
$nested_array = array();
$nested_array["skill_slug"] = $term->slug;
$nested_array["criterion_slug"] = $criterion_slug;
$nested_array["criterion_value"] = $generic_field_value;
$rating_array[] = $nested_array;
endwhile;
endif;
update_post_meta($post_id,'wpcf-expert-review-rating', $rating_array);
// Reset Post Data
wp_reset_postdata();
}
}
}
}
I tried to do some debugging on end and it seems like the code is working until $generic_field as I can see an output: taxonomy-termslug-criterionslug. However, the update_post_meta ( ) is not inserting data in the post even if I pass a constant. May be it is not picking the $post_id from cred_save_data?
What could I be missing?
I also ran a debug log but could not find anything specific.
[22-Jan-2021 04:37:29 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:29 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:29 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:29 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:29 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:30 UTC] PHP Notice: Undefined index: rating-market-analysis-data-collection in /srv/htdocs/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(65) : eval()'d code on line 52
[22-Jan-2021 04:37:32 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:32 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:32 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:33 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:33 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:33 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:33 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:33 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:36 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:36 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:36 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:36 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:36 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:37 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:37 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:37 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:37:37 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:37:37 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:05 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:05 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:05 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:05 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:05 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:05 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:05 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:05 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:05 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:05 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:11 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:11 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:11 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:11 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:11 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:15 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:15 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:15 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:15 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:15 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:17 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:17 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:17 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:17 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:17 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:18 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:18 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:18 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:18 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:18 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:18 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:18 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:18 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:18 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:18 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:20 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:20 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:20 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:20 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:20 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:24 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:24 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:24 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:24 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:24 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:24 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:24 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:24 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:24 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:24 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:25 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:25 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:25 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:25 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:25 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:28 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:28 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:28 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:28 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:28 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:29 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:29 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:29 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:29 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:29 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:31 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:31 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:31 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:31 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:31 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:31 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:31 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:31 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:31 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:31 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:32 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:34 UTC] PHP Notice: is_archive was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:34 UTC] PHP Notice: is_home was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:34 UTC] PHP Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /wordpress/core/5.6/wp-includes/functions.php on line 5311
[22-Jan-2021 04:38:34 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
[22-Jan-2021 04:38:34 UTC] PHP Notice: Undefined index: name in /wordpress/core/5.6/wp-includes/class-wp-list-util.php on line 161
You'll need to add debug logging intermittently throughout the code to understand why it's failing. For example:
add_action('cred_save_data', 'add_rubric_results_to_array',10,2); function add_rubric_results_to_array($post_id, $form_data) { $forms = array( 12080, 12090 ); if ( in_array( $form_data['id'], $forms ) ) { $rating_array = array(); $expert_match_terms = array(); $expert_match_terms_slug = array(); $expert_match_id = $_GET['expert-match-id']; // $expert_match_id = $toolset_get_related_post($post_id, 'expert-match-id-to-expert-review', 'parent', 'publish'); $expert_match_terms = get_the_terms( $expert_match_id, 'skill-category' ); error_log('expert match terms'); error_log(print_r($expert_match_terms, true)); if ( $expert_match_terms && ! is_wp_error( $expert_match_terms ) ) { foreach ( $expert_match_terms as $term ) { // $expert_match_terms_slug[] = $term->slug; $args = array(); $args = array( 'post_type' => 'criterion', 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'skill-category', 'field' => 'slug', 'terms' => $term->slug ) ), ); $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // Do Stuff $criterion_post = get_post(); error_log('criterion post'); error_log(print_r($criterion_post, true)); $criterion_slug = $criterion_post->post_name; //create dynamic field slug with format: rating-taxonomyslug-criterionslug $generic_field = "rating-"; $generic_field .=$term->slug; $generic_field .="-"; $generic_field .=$criterion_slug; $generic_field_value = $_POST[$generic_field]; error_log('generic field'); error_log($generic_field); error_log('generic field value'); error_log($generic_field_value); $nested_array = array(); $nested_array["skill_slug"] = $term->slug; $nested_array["criterion_slug"] = $criterion_slug; $nested_array["criterion_value"] = $generic_field_value; $rating_array[] = $nested_array; endwhile; endif; error_log('post id'); error_log($post_id); update_post_meta($post_id,'wpcf-expert-review-rating', $rating_array); // Reset Post Data wp_reset_postdata(); } } } }
Thanks for the help, man! The whole thing worked. I am able to add a json to the custom field in the expert review post type with the right information.
Well done, thanks for the update. I'll close here. Feel free to reopen or start a new ticket if you have problems.