Mark
Forum Replies Created
-
Hello @wpmudev-support8
I hadn’t realised that and have changed everything back and tested again.
Top is a manually entered nominee and bottom is using front end form: https://a.cl.ly/bLulbQ8A
As you can see some data isn’t being pulled through.
@wpmudevsupport13 I have just sent the email. Thank you!
- This reply was modified 3 years, 3 months ago by Mark.
Thats not working for me at all. In fact, when submitting the form the post isn’t being linked with the award nor the award year https://a.cl.ly/P8u2XDzq
I’d be more than happy to give you access to the site to have a deeper look.
<?php add_action( 'awards', 'awards', 11, 3 ); function awards( $post_id, $field, $data ) { $cats = array( 434,433 ); // category IDs, one or more comma separated; posts in this category will be tagged $tags = array( 3 ); // define tags IDs - one or more, comma separated $tax = 'awards_year'; // name of taxonomy tag to be used, post_tag is default if ( in_array( $data['category'], $cats ) ) { wp_set_post_terms( $post_id, $tags, $tax ); } } ?><?php add_filter( 'awards', function( $wrappers, $model_id ) { if( $model_id != 263 ){ return $wrappers; } $select_fields_data = array( 'select-1' => 'categories', ); foreach ( $wrappers as $wrapper_key => $wrapper ) { if ( ! isset( $wrapper[ 'fields' ] ) ) { continue; } if ( isset( $select_fields_data[ $wrapper[ 'fields' ][ 0 ][ 'element_id' ] ] ) && ! empty( $select_fields_data[ $wrapper[ 'fields' ][ 0 ][ 'element_id' ] ] ) ) { $p_args = array('post_type' => $select_fields_data[ $wrapper[ 'fields' ][ 0 ][ 'element_id' ] ], 'numberposts' => -1, ); $posts = get_posts( $p_args ); if ( ! empty( $posts ) ) { $new_options = array(); $opt_data = array(); foreach( $posts as $post ) { $new_options[] = array( 'label' => $post->post_title, 'value' => $post->ID, 'limit' => '', 'key' => forminator_unique_key(), ); $opt_data['options'] = $new_options; } $select_field = Forminator_API::get_form_field( $model_id, $wrapper['fields'][0]['element_id'], true ); if( $select_field ){ if( $select_field['options'][0]['label'] != $opt_data['options'][0]['label'] ){ Forminator_API::update_form_field( $model_id, $wrapper['fields'][0]['element_id'], $opt_data ); $wrappers[ $wrapper_key ][ 'fields' ][ 0 ][ 'options' ] = $new_options; } } } } } return $wrappers; }, 10, 2 ); add_filter( 'forminator_replace_form_data', function( $content, $data, $fields ) { if( $data['form_id'] != 263 ){ return $content; } if ( ! empty( $content ) ) { return $content; } $form_fields = Forminator_API::get_form_fields( $data['form_id'] ); $data_field = ''; foreach($data as $key => $value){ if ( strpos( $key, 'select' ) !== false ) { $values = ''; $field_value = isset( $data[ $key ] ) ? $data[ $key ] : null; if ( ! is_null( $field_value ) ) { $fields_slugs = wp_list_pluck( $form_fields, 'slug' ); $field_key = array_search( $key, $fields_slugs, true ); $field_options = false !== $field_key && ! empty( $form_fields[ $field_key ]->raw['options'] ) ? wp_list_pluck( $form_fields[ $field_key ]->options, 'label', 'value' ) : array(); if ( ! isset( $field_options[ $field_value ] ) && isset( $_POST[ $key ] ) ) { return sanitize_text_field( $_POST[ $key ] ); } } } } return $content; }, 10, 3 ); ?>Unfortunately, I have discovered that on submitting the form the information is not passed correctly. For example, the categories and awards year isn’t recorded.
Ok. I think thats working… I have also renamed the class so that I can target it for auto populating the select field.
I have a few other things which you may be able to help with…
1. Text area title seems to be hidden behind the field? https://a.cl.ly/Jrupeek8
2. I need to make sure “Awards Year” which is a tag within the Awards category is applied to nominees. For example this years nominees would be tagged with “2023”. How do I do this without giving the person the option to choose which year?
@wpmudevsupport12 It is not pulling through all 8 awards despite following all steps above. Would you like admin access?
Hello @wpmudevsupport11
I did explain it clearly I thought but perhaps further clarification would be helpful here.
Awards Category is
wp-admin/edit.php?post_type=categories(Awards) categories
Nominees iswp-admin/edit.php?post_type=nomineeThese are linked with a relationship field within Custom Fields Pro. All custom post types are created with CPT UI.
I would like the Awards (categories) to be populated within a select field in Forminator.
- This reply was modified 3 years, 3 months ago by Mark.
Here you go Zafer.
Form export: https://pastebin.com/RtzEgGdX
Code: https://pastebin.com/67UjVaFCHello again,
I fixed the query string, it wasn’t anything to do with what we’re doing here thankfully.
1. I understand that if you remove the code that my colleague shared – the issue goes away, right?
No, the error has been resolved now so just need to get the code working and select field populating with the categories now.
2. to make sure – the issue is happening “right away” when you visit the page with the form or after you attempt to submit the form only?
Form submits fine but the select field is not populated with custom post type “categories”
3. could you share screenshot of the entire custom code (the one we shared but after your modifications – “as is”, how you added it)? Also, did you add it as MU plugin or, by any chance, put in theme’s functions PHP file or some kind of theme’s “custom code” Option?
Code: https://a.cl.ly/RBurmABy
File location: https://a.cl.ly/L1uDXb6PHey @wpmudevsupport14! Thanks for that! Done as requested with changing ID and post type of the Awards categories https://a.cl.ly/geuERoWp
However, the form disappears from the page and I get the following query appear (which is a custom query within Themeco’s “PRO” theme: https://a.cl.ly/xQuRwYL9
Bit late to the party here but; yep, working fine now. Thanks.
I also have this issue. Very annoying! https://a.cl.ly/12u7yzk7
Forum: Plugins
In reply to: [SmartCrawl SEO checker, analyzer & optimizer] Permalinks placementHello Adam,
It’s not really a bug, more annoying UI. Surely the counter should be next to permalink rather than below it causing a massive gap –> https://a.cl.ly/xQuxGbAJ
Am I able to disable this SmartCrawl feature if you don’t plan on fixing it?
Forum: Plugins
In reply to: [WooCommerce] Extra shipping charge@jricketts4 that works great! Thanks so much.