• Hello I was wondering if anyone could point my in n the right direction. What I’m trying to do is create a clan roster and use the wordpress user id’s that way I don’t have to keep re-entering them via html.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I do not know what “clan roster” is, and when I search that term on the Internet there is only things related to video game teams. Anyway, you can extract the user’s data from the WordPress database with a SQL query like this, where “wp_users” is the name of the table:

    SELECT * FROM wp_users ORDER BY ID ASC;
    

    And if you want to combine this query with the WordPress functions then you can use the global variable “wpdb” and the “get_results” method to extract the information in a way that you can manipulate with PHP, like this:

    global $wpdb;
    if ( $wpdb ) {
      $query = 'SELECT * FROM wp_users ORDER BY ID ASC';
      $results = $wpdb->get_results( $query, OBJECT );
      var_dump( $results );
    }
    
    Thread Starter funeral

    (@funeral)

    Yeah im trying to build a clan roster with certain users registered on my site
    so lets say clan leader is wordpress id 1/or specific username
    co-leader is another id/specific name

    creating a table to put these in i just dont know how to grab specific names i want

    thanks for the help! trying to learn queries here hah!

    To extract the data of an user following a filter you can use the keyword “WHERE” in conjunction with the “SELECT” statement as you can see here [1]. Following my previous example, you could run a SQL query like this to extra the information of one user account.

    SELECT * FROM wp_users WHERE user_login = 'admin' LIMIT 1;
    

    WordPress has a page with information [2] of how to use the global variable “wpdb” to query the database, so if you want to learn a few tricks to customize your website check that reference.

    [1] https://dev.mysql.com/doc/refman/5.7/en/select.html
    [2] https://codex.www.ads-software.com/Class_Reference/wpdb

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Pull user database with mysql query?’ is closed to new replies.