Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ADDING CUSTOM FIELDS TO THE SUBMISSION FORM IS NOT ACTIVELY SUPPORTED!
- // However, if you would like to add a category dropdown to the form, this should help get you started.
- // This will only work in Site Review v5
- //
- /**
- * Adds a category dropdown field to the Site Reviews submission form.
- * Paste this in your active theme's functions.php file.
- * @param array $fields
- * @return array
- */
- add_filter('site-reviews/config/forms/review-form', function ($fields) {
- $categories = get_terms([
- 'count' => false,
- 'fields' => 'id=>name',
- 'hide_empty' => false,
- 'taxonomy' => glsr()->taxonomy,
- ]);
- if (is_wp_error($categories)) {
- glsr_log()->error($categories->get_error_message());
- return $fields;
- }
- $fields['assigned_terms'] = [
- 'label' => 'Category',
- 'required' => true,
- 'options' => ['' => __('Select a category', 'site-reviews')] + $categories,
- 'type' => 'select',
- ];
- return $fields;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement