Support » Plugin: WP-Members: Membership Framework » [Plugin: WP-Members] Query an SQL database?

  • Resolved skblues



    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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chad Butler


    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.

    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
    	If they didn't match, you'd return an error;
    	if they did, you could allow registration to

    Hi Chad,

    Thanks for your response. Yes, this is probably beyond what I can work with, so I will find another solution. Thank you!

    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


    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WP-Members] Query an SQL database?’ is closed to new replies.