Custom select field option value
-
Hi,
Before V5, I used a form to review at the category level.
I created a custom field to let the user choose which product the review is assigned to.After submission, I used a hook to correctly assign the review to the product.
It isn’t working anymore.
Here is the end of my function to create the custom field :
if( $query->have_posts() ) { $config[$cat_slug] = [ 'label' => $label, 'type' => 'select', 'required' => true, ]; while( $query->have_posts() ) { $query->the_post(); $config[$cat_slug]['options'][get_the_id()] = get_the_title( get_the_id() ); } wp_reset_postdata(); } } return $config; } add_filter('site-reviews/config/forms/review-form' , 'MSW_add_custom_field_to_site_review_partie_boutique');
The problem is that the option values ??are no longer the post ID but a counter that increments.
I can no longer find the post ID to assign it with the
site-reviews/review/created
hookAfter submission, I used this snippet on the hook to assign the review :
if ( isset($_POST['site-reviews']['e-books'] ) ) { $id_produit = intval( $_POST['site-reviews']['e-books'] ); update_post_meta( $id_review , '_assigned_to' , $id_produit ); }
This will not work either because you have restructured the functioning of the plugin in database. Is there a new simple solution to assign a review to a post using PHP ?
I now need to insert into the
glsr_assigned_posts
table and not update a post meta…I hope it’s clear
Thanks for your help ??- This topic was modified 3 years, 9 months ago by .
- This topic was modified 3 years, 9 months ago by .
- This topic was modified 3 years, 9 months ago by .
- This topic was modified 3 years, 9 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘Custom select field option value’ is closed to new replies.