Forum Replies Created
-
AuthorPosts
-
July 20, 2018 at 3:25 am in reply to: Undefined index: user_id in /…/piklist/includes/class-piklist.php on line 1098 #9134
sthamMemberThank you so much Steve.
April 13, 2018 at 10:06 pm in reply to: Uploader field only saves one file instead of multiple #8840
sthamMemberThanks so much, Steve! Works like a dream now.
December 6, 2016 at 3:41 am in reply to: Parameters in custom validation rules callback returning 0 and empty array #7614
sthamMemberSolved it! But I’ll explain here in case it might help someone else out. I basically referred to the
validate_emailfunction inclass-piklist-validate.php(line 992) to do it.There are 5 parameters, not 3 –
$index,$value,$options,$field,$fields. Based on the documentation, these parameters are:@param int $index The field index being checked. @param mixed $value The value of the field. @param array $options The options. @param array $field The field object. @param array $fields Collection of fields.So my code now looks like this:
function smm_validate_single_choice( $index, $value, $options, $field, $fields ) { if ( is_array( $value ) ) { $value = $value[0]; } return ( array_key_exists( (string) $value, $field['choices'] ) ) ? true : __( 'does not have a valid selection.', 'smm' ); }June 10, 2016 at 7:57 am in reply to: Function to programatically save add-more field values in settings? #6664
sthamMemberHi Steve,
Thanks for the response. I finally managed to get everything working.
From within
register_activation_hook, I put together an array (based on the same format that I discovered in thewp_optiontable) and usedupdate_optionto save it. The values then showed up perfectly in the settings page.$defaults = array( 'my_addmore_field_1' => array( 'Swimming Pool', 'Gym' ), 'my_addmore_field_2' => array( 'Lorem', 'Ipsum' ) ); update_option( 'my_option', $defaults );But the defaults are a good idea too. Will keep that in mind for future reference.
Thanks again!
June 9, 2016 at 6:25 am in reply to: Function to programatically save add-more field values in settings? #6641
sthamMemberOops! Made a big mistake in my earlier response. The data IS saved with update_option(), not using transients as I previously thought.
Sorry for the confusion. Been staring at codes for too many hours I think.
June 9, 2016 at 4:43 am in reply to: Function to programatically save add-more field values in settings? #6639
sthamMemberThank you, Jason and bicho44. Those pointers were very helpful.
After some more digging into the database, here’s what I found (in case it might help someone else):
1. The add-mores are stored serialized.
2. The data is stored using set_transient() based on their option_name in the wp_option table.
3. An array of all the fields is passed through serialize() and md5(), and the resulting string forms part of the transient name.I haven’t quite gotten everything to work yet but I hope I’m on the right track.
Attachments:
You must be logged in to view attached files. -
AuthorPosts