Get custom_user meta value and add entry

You need to pass get_user_meta a third parameter to prevent it from returning an array. That is where the mistake is, not with the add/update functions. $invoice_meta = get_user_meta( $_GET[‘id’], ‘invoices’, true); You will need to clean up any data already in the database or the existing nested arrays will still cause trouble.

Matching usermeta at registration to categories of content

Are you looking for this? function convertInterestCategory() { $interest_categories = array( ‘interest_disaster’, ‘interest_animals’, ‘interest_women’, ‘interest_seniors’, ‘interest_hunger_health’, ‘interest_education’, ‘interest_environment’, ‘interest_arts_culture’, ‘interest_children_youth’, ‘interest_other’, ‘interest_mentoring’, ‘interest_poverty_urban’ ); $current_user = wp_get_current_user(); $user_values = get_user_meta( $current_user->ID ); foreach ( $interest_categories as $interest_category ) { if ( isset( $user_values[$interest_category][0] ) ) echo $user_values[$interest_category][0]; } }

Display custom posts in checkbox list

{// post_list case ‘post_list_produktkrav’: $items = get_posts( array ( ‘post_type’ => $field[‘post_type’], ‘posts_per_page’ => -1 )); foreach($items as $item) { echo ‘<input type=”checkbox” value=”‘.$item->ID.'” name=”‘.$field_related[‘id’].'[]” id=”‘.$item->ID.'”‘,$meta_related && in_array($item->ID, $meta_related) ? ‘ checked=”checked”‘ : ”,’ /> <label for=”‘.$item->ID.'”>’.$item->post_title.'</label><br />’; } // end foreach break;}

Dynamically name array in WordPress loop – add/get values

From the PHP manual: Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ‘[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*’ Hence before diving into your code further: It would need much … Read more

Using class id from array for query

Try this after your $wpdb query: // collect calendar id’s $ids = array(); foreach( $calendar_entries as $calendar_entries): array_push( $ids, $calendar_entries->id ); endforeach; // query the above calendar id’s $args = array( ‘post_type’ => ‘post’, ‘post__in’ => $ids, ‘orderby’ => ‘id’, ‘order’ => ‘DESC’ ); $query = new WP_Query( $args ); You can also modify the … Read more

!in_array doesnt recognize category

Try it like this: if ( $query->have_posts() ) { $categories = $category_ids = array(); while ( $query->have_posts() ) { $query->the_post(); foreach ( ( get_the_category() ) as $category ) { if ( ! in_array( $category->term_id, $category_ids ) ) { $category_ids[] = $category->term_id; $categories[] = $category; } } }; } get_the_category() returns an array of objects. I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)