Title: [Plugin: WP-Members] Query an SQL database?
Last modified: August 20, 2016

---

# [Plugin: WP-Members] Query an SQL database?

 *  Resolved [skblues](https://wordpress.org/support/users/skblues/)
 * (@skblues)
 * [14 years ago](https://wordpress.org/support/topic/plugin-wp-members-query-an-sql-database/)
 * Hello,
 * I am trying to help an organization set up a members area that offers free content
   to members only. When a user registers, they want the site to query an SQL database
   for the email and grant or deny access based on that. Is it possible to set this
   up, and if so, is there documentation? I am not a database programmer by any 
   means, and I’m relatively new to WordPress and haven’t used this plugin before.
 * Any help would be greatly appreciated!
 * [http://wordpress.org/extend/plugins/wp-members/](http://wordpress.org/extend/plugins/wp-members/)

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

 *  Plugin Author [Chad Butler](https://wordpress.org/support/users/cbutlerjr/)
 * (@cbutlerjr)
 * [14 years ago](https://wordpress.org/support/topic/plugin-wp-members-query-an-sql-database/#post-2765797)
 * Yes, it can be done. However, to pull it off, you (or whoever is going to do 
   the work) will not only need to know how to query a database, but also how to
   use WordPress hooks.
 * The plugin has an action hook that comes in the registration process before the
   user is registered. Hooking in at this point would allow you to take the email
   the user is using to register and verify it against your other database.
 * The hook is wpmem_pre_register_data and it is documented in the plugin’s User
   Guide.
 * I don’t know what your php skills are, but if you have limited skills with databases
   and you are new to WordPress, I’ll be honest and say you are going to run into
   some challenges.
 *     ```
       <?php
       add_action( 'wpmem_pre_register_data', 'my_reg_hook', 1 );
   
       function my_reg_hook( $fields ) {
   
       	/*
       	$fields is an array of the registration fields
       	with data at the point where the plugin has
       	done its validation, but the user hasn't been
       	inserted yet.
   
       	This is where you would need to query the other
       	database (for which you'd obviously need a
       	connection to) and compare the email in the
       	$fields array with the email you have in your
       	database.
   
       	If they didn't match, you'd return an error;
       	if they did, you could allow registration to
       	proceed.
       	*/
       }
       ?>
       ```
   
 *  Thread Starter [skblues](https://wordpress.org/support/users/skblues/)
 * (@skblues)
 * [14 years ago](https://wordpress.org/support/topic/plugin-wp-members-query-an-sql-database/#post-2765800)
 * Hi Chad,
 * Thanks for your response. Yes, this is probably beyond what I can work with, 
   so I will find another solution. Thank you!
 *  [rkenne02](https://wordpress.org/support/users/rkenne02/)
 * (@rkenne02)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/plugin-wp-members-query-an-sql-database/#post-2765876)
 * I’ve added a field to wp-members registration form and would like to get access
   to [email] and [the other field] to use to display on a page and also use to 
   access an external database. How can I display this information on a page?
 *  Plugin Author [Chad Butler](https://wordpress.org/support/users/cbutlerjr/)
 * (@cbutlerjr)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/plugin-wp-members-query-an-sql-database/#post-2765880)
 * Yes – but rather than come into a resolved thread, you should start a new one…
 * You could use the shortcode [wp-members field=”name-of-field”] or WordPress [get_user_meta](http://codex.wordpress.org/Function_Reference/get_user_meta)

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

The topic ‘[Plugin: WP-Members] Query an SQL database?’ is closed to new replies.

 * ![](https://ps.w.org/wp-members/assets/icon-256x256.png?rev=1226414)
 * [WP-Members Membership Plugin](https://wordpress.org/plugins/wp-members/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-members/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-members/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-members/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-members/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-members/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Chad Butler](https://wordpress.org/support/users/cbutlerjr/)
 * Last activity: [13 years, 12 months ago](https://wordpress.org/support/topic/plugin-wp-members-query-an-sql-database/#post-2765880)
 * Status: resolved