Search Users by Last Name with a Link to the Author Page


prepare() is a fast and safe method for performing a MySQL query $stmt = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta AS um WHERE ( um.meta_key='last_name' AND um.meta_value LIKE '%%%s%%') OR (um.meta_key='last_name' AND um.meta_value LIKE '%%%s%%') ORDER BY um.meta_value LIMIT 150", $usersearch, $usersearch ); //results are cached in the variable $results using get_col() $results = $wpdb->get_col( $stmt ); } ?>
"; echo ""; //now we can loop through the $metanames variable foreach($metanames as $m){ echo ""; } ?> "; ?> View "; echo ""; } ?>
"; //$u is going to be the users id echo $u; echo ""; echo esc_attr( get_user_meta( $u, $m, true ) ); echo "