Reformat data within a nested array

A quick solution would be to change this: //rename the array keys foreach( $data as &$new_values ) { $new_values[‘user_id’] = $new_values[0]; unset( $new_values[0] ); $new_values[‘product_id’] = $new_values[1]; unset( $new_values[1] ); } Into this: //rename the array keys foreach( $data as &$new_values ) { $new_values[‘user_id’] = (string) $new_values[0]; unset( $new_values[0] ); $new_values[‘product_id’] = (string) $new_values[1]; unset( … Read more

WP_Post is not from correct array

get_the_ID gives you the ID of the current post, but at no point during that loop do you change what the current post is. It’s always the last post processed in the previous loop because that’s the last time you called the_post(). This is why you always get the same ID. Instead, store the ID: … Read more

Page returning ID from array, how to return the correct values for post in acf wordpress

I played with the code for a bit longer and managed to get it working. Answer below add_filter( ‘gform_pre_render’, ‘freetrial_studios’ ); add_filter( ‘gform_pre_validation’, ‘freetrial_studios’ ); add_filter( ‘gform_pre_submission_filter’, ‘freetrial_studios’ ); add_filter( ‘gform_admin_pre_render’, ‘freetrial_studios’ ); function freetrial_studios( $form ) { foreach ( $form[‘fields’] as &$field ) { if ( $field->type != ‘select’ || strpos( $field->cssClass, ‘studio-list’ ) … Read more

Need help getting a certain value out of a multi dimensional array

The reason you get the “First” Array is that you don’t use the “single” option of the get_user_meta function. Try this: $arr = get_user_meta($user->ID, ‘wpcf-team-experience-member-type’,true); $options = array(); if(is_array($arr)){ foreach($arr as $key => $value){ foreach($value as $arrvalue){ $options[] = $arrvalue; } } } var_dump($options); This should dump all the options that maybe are in there. … Read more

Trying to get custom post type attachment images to function in indexed array

Managed to find a solution that display the array correctly: $attachments = get_children( array( ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => ‘inherit’, ‘post_mime_type’ => ‘image’, ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order ASC’ ) ); $imgArray = array(); $counter = 0; foreach ( $attachments as $attachment_id => $attachment ) { $imgArray[$counter] = … Read more