Title: metakeys SQL query
Last modified: November 5, 2021

---

# metakeys SQL query

 *  Resolved [Geoff](https://wordpress.org/support/users/geoffrsmith/)
 * (@geoffrsmith)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/metakeys-sql-query/)
 * Hi,
    I have ‘CUSTOM_USER_TABLE’ and ‘CUSTOM_USER_META_TABLE’ constants defined,
   which is causing get_user_meta_keys() in class-wprus-settings.php to return empty.
   Is there any reason why {$wpdb->usermeta} could not be used in place of {$wpdb-
   >prefix}usermeta in the sql query? Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Alexandre Froger](https://wordpress.org/support/users/frogerme/)
 * (@frogerme)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/metakeys-sql-query/#post-15039305)
 * Hi [@geoffrsmith](https://wordpress.org/support/users/geoffrsmith/)
    If you are
   speaking about line 820 of [class-wprus-settings.php](https://plugins.trac.wordpress.org/browser/wp-remote-users-sync/trunk/inc/class-wprus-settings.php)(`
   FROM {$wpdb->prefix}usermeta m`), it is using `{$wpdb->prefix}` in the sql query.
 * This is because it is best practice, and mandatory to make sure prefixes set 
   in `wp-config` gets taken into account.
    See [this post on WordPress Stackexchange](https://wordpress.stackexchange.com/questions/189982/is-it-mandatory-to-use-wpdb-prefix-in-custom-tables).
    -  This reply was modified 4 years, 7 months ago by [Alexandre Froger](https://wordpress.org/support/users/frogerme/).
 *  Thread Starter [Geoff](https://wordpress.org/support/users/geoffrsmith/)
 * (@geoffrsmith)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/metakeys-sql-query/#post-15046210)
 * Hi,
    Thanks for taking the time to respond, and yes that was the specific code
   that I was referring to.
 * I believe that the final section of the linked stackexchange post is pertinent
   in my case:
 * > However, multisite uses only one user table, since all users are network users.
   > So if the query involves the wp_users or wp_usermeta tables, you must use $
   > wpdb->users or $wpdb->usermeta respectively
 * I have ‘CUSTOM_USER_TABLE’ and ‘CUSTOM_USER_META_TABLE’ defined in wp-config 
   for subdomain sites sharing the same database as the main site, and need to link
   sign-in on any one of these site to another site using a separate database.
 * As the main database only has a single user and usermeta table for all connected
   site, $wpdb->prefix only works correctly for those specific tables on the main
   domain.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘metakeys SQL query’ is closed to new replies.

 * ![](https://ps.w.org/wp-remote-users-sync/assets/icon-256x256.png?rev=2260728)
 * [WP Remote Users Sync](https://wordpress.org/plugins/wp-remote-users-sync/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-remote-users-sync/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-remote-users-sync/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-remote-users-sync/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-remote-users-sync/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-remote-users-sync/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Geoff](https://wordpress.org/support/users/geoffrsmith/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/metakeys-sql-query/#post-15046210)
 * Status: resolved