Forum Replies Created
-
AuthorPosts
-
StephenParticipantI ran into some problems with my code above, not realizing that this code ALSO runs in the admin, so I needed to modify my code thus:
if (isset($fields_data['_'])) { //checks that this is a front end form submit $formobjID = $fields_data['post']['post_type']['object_id']; //gets the object ID from the form data $issues = $fields_data['taxonomy']['my_issues']['request_value']; if (is_array($issues)) { // checks for array $issueIDS = array_map('intval', $issues); //converts to int, because they are strings when submitted for some reason } else { $issueIDS = intval($issues); //is single value } $locations = $fields_data['taxonomy']['my_locations']['request_value']; if (is_array($locations)) { $locationsIDS = array_map('intval', $locations); } else { $locationsIDS = intval($locations); } wp_set_object_terms( $formobjID,$issueIDS, 'my_issues' ); wp_set_object_terms( $formobjID, $locationsIDS, 'my_locations' ); }Again, hope someone else finds this useful.
StephenParticipantWell, in case this helps anyone else out, I made a quick and (very) dirty change to class-piklist-form.php. This change is to account for my two taxonomies, the first one ‘issues’ that is a multi select checkbox list and the second ‘locations’ which is a simple single select dropdown.
Around line 3292, just after
self::$form_submission = $fields_data;I added the following (customize for your taxonomies and list types):
$formobjID = $fields_data['post']['post_type']['object_id']; //gets the object ID from the form data $issues = $fields_data['taxonomy']['my_issues']['request_value']; // gets my issue array submitted $issueIDS = array_map('intval', $issues); //converts to int, because they are strings when submitted for some reason $locations = $fields_data['taxonomy']['my_locations']['request_value']; $locationsIDS = intval($locations); wp_set_object_terms( $formobjID,$issueIDS, 'my_issues' ); wp_set_object_terms( $formobjID, $locationsIDS, 'my_locations' );
StephenParticipantThis is a pretty major bug for me, is there any workaround or has anyone pinpointed where the problem is in the code? I will try to take a look…
February 18, 2017 at 3:33 am in reply to: Error in saving taxonomy from front-end form for custom post type #7796
StephenParticipantI am having this same issue, taxonomy items from front end are not saving. Is there a workaround or bugfix somewhere?
StephenParticipantWell, I ended up removing even more fields, and making some do double duty. I have ended up with a leaner set that is about 50% better performance (because there are 50% fewer total fields). I guess this is the best we can do. If anyone has any better suggestions, I am all ears.
StephenParticipantSure here it is just slightly simplified:
<?php /* Title: my-component Fields Post Type: my-component Order: 10 */ piklist('field', array( 'type' => 'datepicker' ,'field' => 'expiration_date' ,'required' => true ,'label' => __('Expiration Date', 'my-component') ,'description' => __('Choose an expiration date', 'my-component') ,'options' => array( 'dateFormat' => 'yy-mm-dd' ) ,'attributes' => array( 'size' => 17 ) ,'on_post_status' => array( 'value' => 'lock' ) )); piklist('field', array( 'type' => 'textarea' ,'field' => 'my_brief_description' ,'label' => __('Brief Description', 'my-component') ,'description' => 'Type your brief description here. It will show up in lists.' //,'value' => '' ,'attributes' => array( 'rows' => 5 ,'cols' => 50 ,'class' => 'large-text' ) )); piklist('field', array( 'type' => 'editor' ,'field' => 'post_content' ,'scope' => 'post' ,'required' => false ,'label' => __('Full Description', 'my-component') ,'description' => __('Type your long description here. It will show up on the detail page.', 'my-component') // ,'value' => '' ,'options' => array( 'wpautop' => true ,'media_buttons' => false ,'shortcode_buttons' => false ,'teeny' => false ,'dfw' => false ,'tinymce' => array( 'resize' => false ,'wp_autoresize_on' => true ) ,'quicktags' => true ,'drag_drop_upload' => false ) ,'on_post_status' => array( 'value' => 'lock' ) )); piklist('field', array( 'type' => 'group' ,'label' => __('Things to do', 'my-component') ,'add_more' => true ,'description' => __('List all the things', 'my-component') ,'fields' => array( array( 'type' => 'select' ,'field' => 'typeofthing' ,'label' => __('type of thing', 'my-component') ,'value' => 'none' ,'required' => true ,'choices' => array( '' => 'Choose thing' ,'thing' => __('thing', 'my-component') ,'thing_two' => __('2', 'my-component') ,'thing_three' => __('3', 'my-component') ,'thing_four' => __('4', 'my-component') ,'thing_five' => __('5', 'my-component') ,'thing_six' => __('6', 'my-component') ,'thing_seven' => __('7', 'my-component') ,'thing_eight' => __('8', 'my-component') ,'thing_nine' => __('9', 'my-component') ,'thing_ten' => __('10', 'my-component') ,'thing_eleven' => __('11', 'my-component') //,'thing_twelve' => __('12', 'my-component') )) // thing FIELDS ,array( 'type' => 'text' ,'field' => 'thing_phonenumber' ,'label' => __('Phone Number', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_who' ,'label' => __('Who to call?', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing' ) ) ) ,array( 'type' => 'editor' ,'field' => 'thing_notes' ,'label' => __('Notes', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing' ) ) ) // thing_two fields ,array( 'type' => 'select' ,'field' => 'thing_two_lookup' ,'label' => __('thing_two_lookup', 'my-component') ,'value' => 'none' ,'choices' => thing_two_lookup_choices() ,'attributes' => array( 'multiple' => 'multiple' // Allow a select field to accept multiple selections ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_two' ) ) ) ,array( 'type' => 'select' ,'field' => 'thing_two_lookup_second' ,'label' => __('thing_two_lookup_second', 'my-component') ,'value' => 'none' ,'choices' => thing_two_lookup_choices_second() ,'attributes' => array( 'multiple' => 'multiple' // Allow a select field to accept multiple selections ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_two' ) ) ) ,array( 'type' => 'editor' ,'field' => 'thing_two_notes' ,'label' => __('Notes', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_two' ) ) ) // thing_three FIELDS ,array( 'type' => 'text' ,'field' => 'thing_three_who' ,'label' => __('thing_three who', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_three' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_three_address' ,'label' => __('thing_three Address', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_three' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_three_subject' ,'label' => __('thing_three Subject', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_three' ) ) ) ,array( 'type' => 'editor' ,'field' => 'thing_three_template' ,'label' => __('thing_three template', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_three' ) ) ) // thing_four FIELDS ,array( 'type' => 'text' ,'field' => 'thing_four_url' ,'label' => __('URL of thing_four', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_four' ) ) ) // thing_five FIELDS ,array( 'type' => 'text' ,'field' => 'thing_five_who' ,'label' => __('thing_five Addresee', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_five' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_five_address' ,'label' => __('thing_five Address', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_five' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_five_address_2' ,'label' => __('thing_five 2', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_five' ) ) ) ,array( 'type' => 'text' ,'field' => 'send_letter_city' ,'label' => __('City', 'my-component') ,'columns' => 5 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_five' ) ) ) ,array( 'type' => 'select' ,'field' => 'thing_five_state' ,'label' => __('thing_five State', 'my-component') ,'columns' => 4 ,'choices' => piklist_get_states() ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_five' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_five_postal_code' ,'label' => __('thing_five Postcode', 'my-component') ,'columns' => 3 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_five' ) ) ) //thing_six FIELDS ,array( 'type' => 'text' ,'field' => 'thing_six_url' ,'label' => __('URL of thing_six', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_six' ) ) ) // thing_seven FIELDS ,array( 'type' => 'text' ,'field' => 'thing_seven_where' ,'label' => __('thing_seven where', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_seven' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_seven_datetime' ,'label' => __('thing_seven time', 'my-component') ,'attributes' => array( 'class' => 'dtpicker' ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_seven' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_seven_datetime_end' ,'label' => __('thing_seven end', 'my-component') ,'attributes' => array( 'class' => 'dtpicker' ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_seven' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_seven_url' ,'label' => __('URL thing_seven', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_seven' ) ) ) // thing_eight FIELDS ,array( 'type' => 'text' ,'field' => 'thing_eight_where' ,'label' => __('Where thing_eight', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_eight' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_eight_datetime' ,'label' => __('thing_eight time', 'my-component') ,'attributes' => array( 'class' => 'dtpicker' ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_eight' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_eight_datetime_end' ,'label' => __('thing_eight end', 'my-component') ,'attributes' => array( 'class' => 'dtpicker' ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_eight' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_eight_url' ,'label' => __('URL thing_eight', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_eight' ) ) ) // thing_nine FIELDS ,array( 'type' => 'text' ,'field' => 'thing_nine_where' ,'label' => __('Where thing_nine', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_nine' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_nine_datetime' ,'label' => __('thing_nine time', 'my-component') ,'attributes' => array( 'class' => 'dtpicker' ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_nine' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_nine_datetime_end' ,'label' => __('thing_nine end', 'my-component') ,'attributes' => array( 'class' => 'dtpicker' ) ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_nine' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_nine_url' ,'label' => __('URL thing_nine', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_nine' ) ) ) // thing_ten FIELDS ,array( 'type' => 'text' ,'field' => 'thing_ten_who' ,'label' => __('thing_ten who', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_ten' ) ) ) ,array( 'type' => 'text' ,'field' => 'thing_ten_url' ,'label' => __('URL thing_ten', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_ten' ) ) ) // thing_eleven FIELDS ,array( 'type' => 'text' ,'field' => 'thing_eleven_url' ,'label' => __('URL thing_eleven', 'my-component') ,'columns' => 12 ,'conditions' => array( array( 'field' => 'typeofthing' ,'value' => 'thing_eleven' ) ) ) ) ,'on_post_status' => array( 'value' => 'lock' ) ));I should add that even after consolidating several of the types above (for example, all of those that just had a url field into a typename/url combo, I only saw a very small performance benefit of a second or two off the 8 second add.
StephenParticipant@alexd, thanks for the suggestion, but this won’t solve the problem for me because (if I am understanding you) it breaks conditions, and I really need them to show based on condition selection. I have been reworking my data structures to try to reduce the number of values stored in the db (and thus the number of fields) but alas, the improvements have been minimal. Each additional group added significantly slows down (1 sec/3 secs/5 secs/8 secs), which is unacceptable since many people will add 4 such groups. Anyone else have any other ideas for speeding this up?
StephenParticipantIt occurs to me that I am having this exact same problem (reported here). I suppose one solution would be to try to structure the data differently so fields are reused (reducing the total number and thus improving performance). Is this completely a JS rendering problem that has no piklist solution?
January 26, 2017 at 11:19 pm in reply to: Contact form inside metabox on any post page (in the admin)? #7757
StephenParticipantThanks I will give it a go!
StephenParticipantNevermind I figured it out. Here is the code if it helps someone:
In my setup plugin:
// DATETIMEPICKER ENQUEUE add_filter('piklist_assets', 'my_assets'); function my_assets($assets) { array_push($assets['scripts'], array( 'handle' => 'datetimepicker' ,'src' => get_template_directory_uri() . '/js/jquery.datetimepicker.full.js' ,'ver' => '2.5.4' ,'deps' => 'jquery' ,'enqueue' => true ,'in_footer' => true ,'admin' => true ,'front' => false )); array_push($assets['scripts'], array( 'handle' => 'dtpickermine' ,'src' => get_template_directory_uri() . '/js/dtpickermine.js' //my jQuery(document).ready code... ,'ver' => '1.0' ,'deps' => 'jquery' ,'enqueue' => true ,'in_footer' => true ,'admin' => true ,'front' => false )); array_push($assets['styles'], array( 'handle' => 'datetimepickerclasses' ,'src' => get_template_directory_uri() . '/js/jquery.datetimepicker.css' ,'ver' => '1.2' ,'enqueue' => true ,'in_footer' => true ,'admin' => true ,'media' => 'screen, projection' )); return $assets; }And then in my meta field definition:
piklist('field', array( 'type' => 'text' ,'field' => 'ae_dtpicker' ,'label' => __('my date time', 'direct-action') ,'attributes' => array( 'class' => 'dtpicker' ) ));
StephenParticipantAnyone have any code examples for how to implement this? Thanks in advance
StephenParticipantAnything at all?
StephenParticipantHi there, I am trying to do something similar, displaying a user edit form on the front-end, and meta data fields show but do not pull data from db and will not save. Do you have any suggestions for a workaround or any idea when the plugin will be updated to accommodate this functionality? Thanks so much for an amazing plugin btw!
November 22, 2016 at 7:49 am in reply to: using piklist_post_types with custom tax will not show in tax archive #7584
StephenParticipantWhile I was preparing my two code versions, I found the problem. In your filter example, you set custom statuses, and I copied those in my initial testing. But if a post is saved with one of those custom statuses, it will not report in the taxonomy, so I guess the tax code needs to be expanded to account for those statuses. Once I added a normal status to the group and saved a post, it showed up in my taxonomy.
(and in changing the code to work with register_post_type, even though I left the custom status examples, they were ignored by the function, so the regular statuses were in place, and thus working)
StephenParticipantnevermind, found the fix in this thread:
https://piklist.com/support/topic/error-when-replacing-editor-and-specifying-scope-as-post/
Which is to go to line 923 in class-piklist-form.php and change it to:
array_push($return, $object->{$field['field']} ? $object->{$field['field']} : $field['value']);hope this helps others! And thanks for an amazing product, I am really loving Piklist.
-
AuthorPosts