Skip to content

Instantly share code, notes, and snippets.

@mehdi-eybak
Last active November 15, 2022 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdi-eybak/7a17e022e73f8a9f73e016958e29bb8a to your computer and use it in GitHub Desktop.
Save mehdi-eybak/7a17e022e73f8a9f73e016958e29bb8a to your computer and use it in GitHub Desktop.
return all WordPress user meta_key through the database
<?php
/**
* Returns all unique meta key from user meta database
*
* @param no parameter right now
* 2 pieces of attractive WordPress code
*/
/**
* The first code example:
*/
function get_user_meta_key() {
global $wpdb;
$select = "SELECT distinct $wpdb->usermeta.meta_key FROM $wpdb->usermeta";
$usermeta = $wpdb->get_col($select);
foreach ($usermeta as $meta_key) {
var_dump($meta_key);
};
}
/**
*The second code example:
*/
function get_user_meta_key() {
global $wpdb;
$usermeta = $wpdb->get_col("SELECT distinct meta_key FROM $wpdb->usermeta" );
foreach ($usermeta as $meta_key) {
var_dump($meta_key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment