Created
December 30, 2015 19:17
-
-
Save mavieth/510080ed9f6778ff8a40 to your computer and use it in GitHub Desktop.
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
| function get_general_users(){ | |
| // WP_User_Query arguments | |
| $args = array ( | |
| 'orderby' => 'id', | |
| 'meta_key' => 'trainer_id', | |
| 'meta_value' => '', | |
| 'meta_compare' => '!=', | |
| 'order' => 'DESC' | |
| ); | |
| // The User Query | |
| $user_query = new WP_User_Query( $args ); | |
| $ret = array(); | |
| // The User Loop | |
| if ( ! empty( $user_query->results ) ) { | |
| foreach ( $user_query->results as $user ) { | |
| array_push($ret, $user); | |
| $id = $user->ID; | |
| $trainerID = get_user_meta($id,'trainer_id'); | |
| $lastCertDate = get_user_meta($id,'last_certification_date'); | |
| if (empty($trainerID)) { | |
| // NO ID | |
| echo "no trainer id"; | |
| // add_user_meta( $id, '_level_of_awesomeness', $awesome_level); | |
| } else { | |
| // Has ID | |
| echo "<ul>"; | |
| echo "<li>" . "Trainer: " . $trainerID[0] . "</li>"; | |
| echo "<li>" . $lastCertDate[0] . "</li>"; | |
| echo "</ul>"; | |
| } | |
| } | |
| } else { | |
| // no users found | |
| } | |
| return $ret; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment