Listing all users through shortcode
-
Please i want to list all users and their data on a page using shortcode, but the code i have only list one user details but am having over 20 different users on my site. how can i make this to list out all users? and secondly how can i make it list out details of only the current user viewing the page?
below is my code.// add the shortcode [myuser-table], tell WP which function to call add_shortcode( 'myuser-table', 'persona_table_shortcode' ); // this function generates the shortcode output function persona_table_shortcode( $args ) { global $wpdb; // Shortcodes RETURN content, so store in a variable to return $results = $wpdb->get_results( ' SELECT * FROM wp_users' ); foreach ( $results AS $row ) { // Modify these to match the database structure $dename = $row->user_login . '</br>'; $depass = $row->user_pass . '</br>'; $deemail = $row->user_email . '</br>'; } $contents = '<table><tbody><tr><td class="tak">FIRST NAME</td><td class="tak">PASSWORD</td><td class="tak">EMAIL</td></tr><tr><td class="tako">'. $dename .'</td><td class="tako">'. $depass .'</td><td class="tako">'. $deemail .'</td></tr></tbody></table>'; // return the table return $contents;
}
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Listing all users through shortcode’ is closed to new replies.