WordPress.org

Ready to get started?Download WordPress

Forums

WP-Members
[resolved] Validating WP-Members registration data (4 posts)

  1. likeabikemike
    Member
    Posted 2 years ago #

    Total newb to both WP and WPMembers, (uh, and php too :) can someone point me in the right direction? I want to do some conditional testing of data submitted with the user registration form/page. Like verify that they've checked all the use agreement boxes, and maybe check for a .edu email address.

    Ultimately, I'd like to programmatically set user level based on their answers.

    I saw some discussion of handling this sort of thing in wpmem_pre_register_data or wpmem_post_register_data "action hooks". Where are these functions, and is that where I need to be looking? I can't find any php files under the wp-members plugin folder containing these strings.

    http://wordpress.org/extend/plugins/wp-members/

  2. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    If you are a newb to WP and php, yet you want to programmatically work with the registration process, you are biting off a pretty big project.

    The hooks you mentioned are part of the plugin, but they work just like other action hooks in WP. Hooks are places in the script that you can "hook into." There can be actions or filters. You might want to tackle understanding how hooks work in WP before you go much further. Then what you are trying to do might make more sense.

    For verification of checkboxes, the plugin should manage that already, if you set them to be required.

    Coming back to the action hooks again, a framework of the pre_register_data hook that will display the results of the registration form that you have to work with (they are passed as an array), and then it will stop execution before insertion (this is just so you can see on the screen as an example of how you might approach working with this).

    <?php
    add_action( 'wpmem_pre_register_data', 'my_reg_action', 1 );
    function my_reg_action( $fields )
    {
    	echo "<pre>"; print_r( $fields ); echo "</pre>";
    	exit();
    }
    ?>
  3. likeabikemike
    Member
    Posted 2 years ago #

    Thanks Chad. Setting some checkbox fields to "required" will meet our needs for now. I'll go back and learn how to code action hooks later. Turns it into even-driven programming. I'm starting to get it.

    One additional question: with the checkbox-type wp-members user fields, I see no way to go back after they're created to modify the "stored value when checked". Any pointers there?

  4. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    Yeah... at some point I do want to add an edit function to the custom field process. But the programming overhead needed is pretty significant so that has taken a backseat for now. If you need to change the value, it is just a matter of deleting the existing field you have and adding a new one with the same option name, but a new checked value. (NOTE: be sure that you account for that if you have users registered already - you might need to do a bulk edit in the usermeta if you needed to change existing users.)

    Hope that helps clarify.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic