WordPress.org

Ready to get started?Download WordPress

Forums

WP-Members
Custom registration form (4 posts)

  1. william.seabrook
    Member
    Posted 2 years ago #

    Hello all..!

    We are developing a website for schools, and it needs a members area for the teachers. So, we need a registration form so the schools can sign up and pay for a set number of teachers to access the resources. Once the schools have signed up, the teachers can then register to gain access.

    Is this doable with WP members?

    Cheers,
    William

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

  2. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    WP-Members does not have an integrated payment gateway. However, it does have a number of action hooks in the registration process that would allow you to programatically hook into a payment system.

    wpmem_pre_register_data gets user registration data after data is validated, but before new user is inserted.

    wpmem_post_register_data gets user registration data after the new user is inserted, but before the new registration email is sent.

    All of the registration data is passed to each of these hooks as an array. Here is an example that will grab the user registration data after insertion, and echo the array results on screen. Note: this is ONLY an example to show the fields and data that are passed with this hook; the call to exit(); will stop execution after this user data is inserted.

    <?php
    add_action( 'wpmem_post_register_data', 'my_reg_hook', 1 );
    
    function my_reg_hook( $fields )
    {
    	echo "<pre>"; print_r( $fields ); echo "</pre>";
    	exit();
    }
    ?>

    (You could test the same with the _pre_register_data hook and you will see similar results, except that there will be no user id at that point as the user has not been inserted.)

  3. william.seabrook
    Member
    Posted 2 years ago #

    Many thanks for your all of your help Chad, I shall take a look.

    Kind regards,
    William

    http://seabrook-associates.com

  4. Chad Butler
    Member
    Plugin Author

    Posted 2 years ago #

    As an update to my original answer, there is a code addition that will be in the next release (scheduled as 2.7.5, but subject to change) that will allow the _pre _data hooks to utilize an error message.

    In the current version, you hook into the action, but if your action requires a custom error message, it was a little difficult to enact.

    When the update is release, you will be able to add an error message in your action like this:

    <?php
    add_action( 'wpmem_pre_register_data', 'my_reg_hook', 1 );
    
    function my_reg_hook( $fields )
    {
    	// doing something that needs to be validated
    
    	if( ! $valid ){
    
    		// the custom process was not validated
    		global $wpmem_themsg;
    		$wpmem_themsg = 'my error message';
    
    		// since an error exists, the action
    		// should exit, not return. otherwise,
    		// the user would be inserted
    		exit();
    	}
    }
    ?>

    If it turns out that this works for what you need, and you need a an error message as part of the process and you can't wait for the new release, you could add this line to wp-members-register.php right after the do_action line for wpmem_pre_register_data and wpmem_pre_update_data:

    if( $wpmem_themsg ){ return $wpmem_themsg; }

    NOTE: this is for creating an error message within an action for wpmem_pre_register_data and wpmem_pre_update_data, if something in the action needs to be validated. It's not relative to creating custom error messages in other places - there is actually a wpmem_msg_dialog filter for that.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.