This is a simple PHP related question (and those are better asked at StackOverflow.com) and you can find if an index exists within a multi-dimensional array by iterating through it and matching.
Something as:
function wpse231889_has_user_voted( $user_id, $post_id ) {
if ( !empty( ( $voters = get_post_meta( $post_id, 'voter' ) ) ) ) {
foreach ( $voters as $voter ) {
if ( !empty( $voter['voter']['post_id'] ) && (int) $user_id == (int) $voter['voter']['post_id'] ) {
return true;
}
}
} return false;
}
Glad it helped.
Related Posts:
- update_post_meta from data in multidimensional array created from a form
- update_post_meta() with a modified array?
- How to get update_post_meta output to include string length
- Retrieving multiple values to the Post Meta (using an array)
- Update post meta does not serialize array
- How to use json_decode a post_meta value? [duplicate]
- Print specific values stored in a post meta array
- Random element in get_post_meta array
- update_post_meta adding to array instead of replacing value
- Add Array record to Meta Post
- How i can extract data
- update_post_meta array issues
- Update Post Meta for Arrays — Remove/Replace Single Value from Multi Dimensional Array
- How do I retrieve a value from a multi – dimensional array using get_post_meta? [duplicate]
- How to extract data from a post meta serialized array?
- Nice way to print_r arrays
- WordPress: How to use post_class() in an echo
- How do I pass an array as an argument to a WP-CLI command?
- How to update single value in multi dimensional Post Meta?
- Comma seperated list of ID’s as an array?
- How to store post meta in an array?
- post__in works but also prints the word Array
- Compare two meta key values against each other inside the get_posts array?
- if is_singular array not working as expected
- How do I update a specific object in an array, in user meta?
- Automatically adding meta data to posts or multiple query help
- Sort a custom post type array numerically
- How to add day number and initial to my post graph?
- How to validate register settings array
- How to use IN array properly in WordPress?
- WordPress Plugin Dev: Using array for WP options
- Only a part of array is stored in transient – what could be causing this?
- How to save data of an input field to an array
- Run a check for multiple meta key values
- Stuck with a Custom Field Check box Array
- Compare with WP Meta Query
- How to Translate a string of an array inside a class?
- How to pass conditional array to wp_localize_script
- Modify foreach loop for social sharing links?
- Combine get_page_by_title to exclude pages from wp_list_pages
- Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
- Selecting and outputting results from DB with an array
- Struggling with array and foreach loop
- How to decipher the following array
- How to display line breaked meta values in table?
- Post meta as array looks like string instead of array
- Organizing and grouping an array by year
- Time & Date on Post – Time Ago Custom Function
- array_filter warning – wp-includes/post.php line 3148
- Hide sidebar if post_type is in array
- Can A Post Meta Field Store multiple values that are not in an array?
- Create Array from custom post type to display a slider
- Obtaining values from objects
- search serialised meta_value for date value?
- Remove “%” from strings in serialized arrays in wp_postmeta
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Matching slug terms from one array to those in array of WP_Term objects to output term names
- change order of images attached to post
- WP Page Options Array
- Array is not working in Filter?
- Update value of a associative array with update_post_meta
- return paginate_comments_links() as array
- Inserting a random number into an array [closed]
- Echo 2 values from one key in Array with get_post_custom
- update_post_meta() updating nested array in Multidimensional array with empty sub-array
- How can I update this array built from post meta data?
- What format is this and how to get value “lal” and “pila” from it
- Taxonomy terms not properly displaying as array
- WordPress, result array of ‘post_name’
- Why are array_slice() and array_chunk() not working?
- Retrieve array items without page ID
- How do i fix this “call_user_func_array()” error
- wp_insert_post($post), add an array of values with update_post_meta
- How to output get_tags array list to select box
- How to add each letter, entity, special character from post title to array
- Remove item from post_meta array via AJAX
- Strange Behavior with update_option
- How to set an array of current usernames
- Show Tags of Custom Post Type outside of Loop
- wp_set_object_terms not accepting variable array
- How do I pull post from standard post format?
- Merge arrays and order set and subset as one
- Get the correct meta_value with get_post_meta
- The writing ( with foreach) of the keys of an array of objects to a new array produces fatal error
- Fetching array of postmeta with $wpdb and in_array conditional
- How can I get a list of custom post IDs into a variable I can use for another function?
- Use $wp_customize->add_control to create a selectable “Designed/Powered By” choices select w/ link in footer?
- using array in wordpress database query
- Updating wordpress user meta data array (unexpected multiple arrays)
- Accessing value from associative array
- Accessing array elements (get_pages)
- Printing out JSON array returned [closed]
- How do i output images from URL’s added to the same custom field key
- Fatal error in my WP
- wp_postmeta store multiple values in one key [closed]
- SQL query add only posts with custom field to array
- Combine two foreach Arrays into one table row
- Populate Array with values from another arrray [closed]
- how to separate array with commas? [closed]
- JSON webhook WP Automator – Help with Syntax [closed]