Forum Replies Created
-
AuthorPosts
-
mcmasterMemberThere’s no error message, but the value remains whatever it was before. I can change it to another non-zero value but not zero.
I have the error isolated on a test site; would you like access to it?
mcmasterMemberp.s. Should have mentioned that I’m using Piklist 0.9.9.8
May 3, 2016 at 6:24 pm in reply to: How can I get the ID of new post created by front-end form? #6424
mcmasterMemberKevin explained that because a form can now create multiple objects, the ID field doesn’t work any more. He suggested using a couple of hooks to grab the ID and stick it into the redirect URL. Here are the functions that did the job. (If you’re not doing a redirect, you’ll just need the first one.)
add_action( 'piklist_save_field-post', 'my_grab_new_post_id' ); function my_grab_new_post_id ( $fields ) { global $mcw_new_post_id; $my_new_post_id = $fields['ID']['object_id']; } add_filter( 'wp_redirect', 'my_stick_new_post_id_in_redirect', 10, 2 ); function my_stick_new_post_id_in_redirect ( $location, $status ) { global $my_new_post_id; return( $location."?ID=$my_new_post_id" ); }May 3, 2016 at 12:50 pm in reply to: How can I get the ID of new post created by front-end form? #6422
mcmasterMemberPosted $_RESULT for the simplified form:
Array ( [_post] => Array ( [post_type] => ticket [post_status] => draft [post_title] => Donna Test [ID] => ) [_post_meta] => Array ( [phone] => 555-555-1212 ) [submit] => Review Order [_] => Array ( [form_id] => theme_ticket_order_form [nonce] => 409df09d78 [fields] => 77fa371f86f4a61bb87df398d2260f27 ) )May 3, 2016 at 12:49 pm in reply to: How can I get the ID of new post created by front-end form? #6421
mcmasterMemberI just simplified the form as it had a lot of code used to figure out what the ticketable events are:
<?php /* Title: Test Order Form Method: post Message: Data saved as a post of type ticket. */ // Set where to save this form piklist('field', array( 'type' => 'hidden', 'scope' => 'post', 'field' => 'post_type', 'value' => 'ticket', )); piklist('field', array( 'type' => 'hidden', 'scope' => 'post', 'field' => 'post_status', 'value' => 'draft', )); // Collect information piklist('field', array( 'type' => 'text', 'scope' => 'post', // post_title is in the wp_posts table 'field' => 'post_title', 'label' => 'Name', 'columns' => 10, 'required' => true )); piklist('field', array( 'type' => 'text', 'scope' => 'post_meta', 'field' => 'phone', 'label' => 'Phone', 'columns' => 10, 'required' => true, )); // New post ID piklist('field', array( 'type' => 'hidden', 'field' => 'ID', 'scope' => 'post', 'required' => false, )); // Submit button piklist('field', array( 'type' => 'submit', 'field' => 'submit', 'value' => 'Review Order', 'attributes' => array( 'class' => 'btn btn-default', ), ));May 3, 2016 at 12:40 pm in reply to: How can I get the ID of new post created by front-end form? #6420
mcmasterMemberJason, thanks so much! The ID is not in either. I started looking at $_POST and then switched to $_REQUEST to make sure I wasn’t missing anything in $_GET. But nothing is coming via $_GET.
I started out using a redirect field, but I was receiving nothing at the target, so then I removed the redirect and just put a
piklist::pre( $_REQUEST )in the beginning of the form page. Here’s what I get:Array ( [_post] => Array ( [post_type] => ticket [post_status] => draft [post_title] => Donna Test [ID] => ) [_post_meta] => Array ( [phone] => 541-738-2973 [email] => [email protected] [tickets_season] => Array ( [0] => 2 ) [tickets_c1878] => Array ( [0] => 0 ) [tickets_c1897] => Array ( [0] => 0 ) [tickets_c1899] => Array ( [0] => 0 ) [tickets_c1931] => Array ( [0] => 1 ) [donation] => [address_1] => 123 X [address_2] => [city_state] => Portland OR [total_due] => 130 [total_paid] => 0 ) [submit] => Review Order [_] => Array ( [form_id] => theme_ticket_order_form [nonce] => 19175e9a65 [fields] => 6615d42e5a870dacde95e626deea7ee2 ) )That’s when I have the hidden ID field in the form; if I remove that field I have no ID column in the
_postarray.Donna
mcmasterMemberThis is a known problem: https://piklist.com/support/topic/0-9-9-6-shortcode-interface-not-working-with-iis/
Donna
mcmasterMemberNo, thankfully my client decided to move to a Linux server. 🙂
I talked with Kevin Miller (Piklist developer) and he thought he had a fix. Evidently it will be in the next release but I don’t know when that’s coming out.
Donna
mcmasterMemberThanks, Steve! Tested v1.9.4 and it’s fixed the problem.
Donna
mcmasterMemberHi, this is the same question as was asked here:
And it was answered with a pointer to here:
And I believe the latter was left as something that will be fixed in the next release.
mcmasterMemberSteve, I’ve been having this problem for some time. I’ve been able to recover data by editing the serialized string in the database to “close up” the array.
I just went through that exercise again, but this time there was a twist. The value was double serialized.
s:3388:"a:17:{i:0;a:5:{s:16:"feature_headline";s:17:"Jan Charten-Brawn";s:13:"feature_image";a:1:{i:0;s:3:"330";}s:12:"feature_text";s:9:"President";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";} ... i:16;a:5:{s:16:"feature_headline";s:10:"Donny Lane";s:13:"feature_image";a:1:{i:0;s:3:"336";}s:12:"feature_text";s:8:"Director";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";}}";I had to remove the extra serialization wrapper in addition to fixing the indices:
a:17:{i:0;a:5:{s:16:"feature_headline";s:17:"Jan Charten-Brawn";s:13:"feature_image";a:1:{i:0;s:3:"330";}s:12:"feature_text";s:9:"President";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";} ... i:16;a:5:{s:16:"feature_headline";s:10:"Donny Lane";s:13:"feature_image";a:1:{i:0;s:3:"336";}s:12:"feature_text";s:8:"Director";s:16:"feature_link_url";s:0:"";s:17:"feature_link_text";s:0:"";}}Hope this may be helpful to someone else as we wait for 1.0. 😉
Donna
mcmasterMemberYes, it’s clear that tutorial at https://piklist.com/user-guide/tutorials/hide-meta-boxes-page-template/ needs updating. Neither piklist_get_file_data nor piklist_add_part filters are executed in 0.9.9.x.
I think they may be replaced with piklist_part_data along with some of the variants in Piklist::process_parts, and also piklist_part_data_parameter? (See file plugins/piklist/includes/class-piklist.php.)
No time to test right now, but let us know if you find the magic formula. 😉
Cheers,
Donna
mcmasterMemberI tried to fix this using Piklist sanitization. The function named in the piklist_sanitization_rules filter (mcw_sanitize_shortcode) was called, but the callback function (mcw_sanitize_shortcode_callback) never got executed.
Did I do something wrong? Or does the shortcode interface not support sanitization rules?
I created these filters and functions:
/** keep shortcodes from barfing on " [ ] chars */ add_filter( 'piklist_sanitization_rules', 'mcw_sanitize_shortcode', 11 ); function mcw_sanitize_shortcode ( $sanitization_rules ) { $sanitization_rules['mcw_shortcode'] = array( 'callback' => 'mcw_sanitize_shortcode_callback' ); return $sanitization_rules; } function mcw_sanitize_shortcode_callback ( $value, $field, $options ) { $reserved_chars = array( '"', '[', ']' ); $encoded_chars = array( '"', '[', ']' ); $return = str_replace( $reserved_chars, $encoded_chars, $value ); return $return; } function mcw_restore_shortcode_chars ( $encoded_value ) { $encoded_chars = array( '"', '[', ']' ); $reserved_chars = array( '"', '[', ']' ); return str_replace( $encoded_chars, $reserved_chars, $encoded_value ); }And here’s my shortcode form:
<?php /* Name: Two-Column Section Description: Create a 2-column section inside a page. Shortcode: mcw-2column Icon: dashicons-controls-pause */ piklist('field', array( 'type' => 'editor', 'field' => 'col_left', 'label' => 'Content for left column', 'columns' => 12, 'options' => array ( 'media_buttons' => false, 'teeny' => true, ), 'sanitize' => array( array( 'type' => 'mcw_shortcode', ), ), )); piklist('field', array( 'type' => 'editor', 'field' => 'col_right', 'label' => 'Content for left column', 'columns' => 12, 'options' => array ( 'media_buttons' => false, 'teeny' => true, ), 'sanitize' => array( array( 'type' => 'mcw_shortcode', ), ), ));and the shortcode output:
<?php /* Shortcode: mcw-2column */ $left = apply_filters( 'the_content', mcw_restore_shortcode_chars( $col_left ) ); $right = apply_filters( 'the_content', mcw_restore_shortcode_chars( $col_right ) ); ?> <div class="two-column row"> <div class="col-sm-6"> <?php echo $left; ?> </div> <div class="col-sm-6"> <?php echo $right; ?> </div> </div>Thanks,
Donna
mcmasterMemberThe beta I was using back then was 0.9.5.x, so it could have changed. The Gist URL has changed, BTW, it is now https://gist.github.com/donnamcmaster/7324cba06b375ef35b5b.
mcmasterMemberThe problem also occurs with square brackets.
-
AuthorPosts