I just figured it out. I didn’t understand associative arrays properly and after doing more research I came up with the following that works:
$user_id = 6 ;
$user_meta_array = array() ;
/* the following WordPress function outputs an associative array */
$user_meta_array = get_user_meta($user_id);
$meta_cnt = -1 ;
/* You need the following loop structure to output nicely */
foreach($user_meta_array as $user_meta =>$mk)
{
$meta_cnt = $meta_cnt + 1 ;
echo('Meta Key: '.$user_meta.'<br/>');
/* Each wp_usermeta key can have multiple values */
$meta_vals_found = false ;
foreach($mk as $mk_each)
{
if(!empty($mk_each))
{
$meta_vals_found = true ;
echo('Meta Value----> '.$mk_each.'<br/>');
}
}
if(!$meta_vals_found)
{
echo('----> No Meta Values Entered<br/>');
}
}
Related Posts:
- the_date() not working
- How to return number of found rows from SELECT query
- WP-API v2 Custom Endpoint Response Formatting
- Get author full name
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Extract the first oembed url inserted on the content of a post
- WP API V2 returning Invalid User ID
- Why does $_SESSION only work when I am logged in?
- How to make an meta_query optional?
- How to show only parents subpages of current page item in vertical menu?
- Limit the_excerpt with max of x characters
- How to use copy() function and paste file in /wp-content/themes directory
- How can update custom meta for all posts
- Sanitize get_query_var() url parameters
- PHP/MySQL issues when running WP on EC2 cloud [closed]
- How to safely remove the footer (twentytwenty)
- ajax_object is not defined when ajax calls the function
- It is a good idea to store values from the global $post if they are used multiple times?
- How do I fetch all comments per post via WP REST API?
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- wp_insert_post not working
- Add htaccess rules with insert_with_markers at beginning of htaccess
- esc_url returns incorrect URL
- Using More Tag in Combination with the_excerpt
- combine Code 1 with Code 2
- Custom Form Processing Issue
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- Reordering Buddy Press profile navigation [closed]
- How can I get the total number of installed importers?
- Ajax date_query not working past the first iteration
- get_terms pagination
- PHP file won’t work in wordpress folder, but works in another virtual host
- How to use thumbnail size of image if I’m only using src to get image
- Use URL Rewrite as well as $_GET parameters in URL?
- I want to add custom add to cart link [closed]
- How to add condition in wordpress loop? [closed]
- Output custom field value to post string
- If no image, bigger text
- showing 2 prices wholesale and normal
- wordpress wp_enqueue_script() not working
- Custom plugin settings link doesn’t append current class to menu item when visited? Why?
- WordPress admin-ajax.php 400 bad request
- Custom Background by Page IDs
- What is the proper way to include a PHP framework into my theme?
- Update post title from external file?
- WordPress plug-in for dynamic download link?
- Help with page nav?
- Design with Elementor and code the rest?
- Can a plugin redirect product page based on IF condition?
- How to use mysql LIKE with wpdb?
- Get all posts as an array ID => Name
- How to store multiple custom meta box
- cURL error 6 on news area, and also won’t auto update
- Custom upload folder
- How to manually trigger a redirect to another page without changing the url address?
- How to use title attributes in sidebar widget?
- Displaying Event within two given time frames
- How to get my [shortcode] rendered on the home page, other pages are fine
- Display movies that apear this day next
- Wp favorites posts by specific category? [closed]
- How to add JS script in specific pages in WordPress?
- Fatal error login WordPress [duplicate]
- Pagination contents not changing in Front page WordPress
- How to select post ID for given parent name with nested prepared queries?
- How do I programmatically add ‘reviews_allowed’ to WooCommerce product?
- Why is values of a global variable returning blank when inserted into database
- How to return html as a string from php for WordPress
- Show Gutenberg facebook embed with a custom theme
- Add code to the header of posts by particular author
- Running a PHP SQL script on a wordpress page
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- Taxonomy Child Term, Counter is staying on 0
- How to apply ‘add two more posts’ to media content?
- How to disable sub menu items from being created?
- Access to “My Site” is missing from the admin bar
- Unable to insert current username into custom table through html form
- add ‘publish metabox’ to Gravity forms edit page/form area
- LinkedIn Share Post Button
- load a wordpress page into another wordpress page using iframe
- How do I modify the Previous and Next Page posts on blog pages to include “previous” and “next” before the links?
- How can i iterate through this shortcode array?
- Explode Content within specific HTML element
- Using get_theme_mod with checkbox to display content
- How do I prevent a folder from reappearing in my home directory?
- Add specific content after specific text in every post
- Styling admin page rows in order of importance (checkboxes)
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- WordPress plugin creating sidebar on the theme/page
- Using existing widget code! [closed]
- Pagenav Not appearing on custom Template
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Automatically load WordPress page on server every XX hours
- PHP Puzzle: Unique Styles with PHP loop
- Open WordPress Page from selected option dropdown
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- Disabling User Email Notifications for Erase Personal Data Utility
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- generate excerpt from the part of big text dump that contains keyword
- How to sort search result by post_title, then by post_content
- Custom Admin Menu Report for Specific User ID