Last active
November 15, 2022 22:04
-
-
Save mehdi-eybak/7a17e022e73f8a9f73e016958e29bb8a to your computer and use it in GitHub Desktop.
return all WordPress user meta_key through the database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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