If you’ve ever wanted to have your visitors fill out one form and be registered or subscribed for more than one service, this plugin makes it easier to do. It is still a work in progress and all configuration is done directly in the plugin file for now.

We use an autoresponder called Infinite Responder, which as far as I know, is the only free PHP choice with the features we want. Now there are other options, such as the Dada Mail Project and phplist, and although there are some plugins or extensions to integrate the forms and management of these autoresponders, I have found no way to integrate WordPress registration with an autoresponder. In other words, you have to choose – do you have your users register with WordPress OR with the autoresponder?

With the Dual Registration plugin for WordPress, a hook in the WordPress registration process is used to register the new user with other systems at the same time. So a user fills out one form to register for your WordPress blog, and also gets subscribed to your autoresponder.

This plugin does not integrate unsubscribe features. This is a planned feature, but for now, just know that users wanting to unsubscribe need to understand they are subscribed in two places.

Download

Once this plugin is a little more developed, I would like to add it to the WordPress.org Plugins Directory. Until then, make sure you check the Usage section, and you can download it here…

Download Dual Registration plugin for WordPress

Usage

This being my first WordPress plugin, I am still learning all the in’s and out’s of developing plugins. I needed this functionality for a specific purpose, so the plugin has the configurations hard-coded in the plugin’s core file. Providing an easy configuration interface for the WordPress Administration area is a top priority for this plugin, but I do not have the time or need for this, yet. Let me know if you need something soon.

Basically, in order to submit a form, several pieces of information are needed: the form field names and values and the form processor location where those values are sent (the form’s action attribute). By tapping into the WordPress registration process, we can get the new user’s information and submit it and other options to another form processor using the PHP curl function (check your host’s PHP info for curl support).

The code is currently tailored for an autoresponder called Infinite Responder, but I believe it can easily be modified to support any form processor. Be sure to configure the variables found in the plugin file, it is very well commented and guides you along. Maybe soon I will update it with an interface and other features.

Source

Since there is only one file, and this is a fairly simple plugin so far, here is the source code so far. Refer to the Usage section for details on how to configure the Dual Registration plugin. I have also added more comments explaining how the plugin works and guides you as you configure it.

< ?php
/*
Plugin Name: Dual Registration Plugin
URI: http://free-web-site-tools.thegadgitech.com/dual-registration
Description: Integrate other web based programs that require registration or
user input already being recieved.  Upon registrering for your blog, the user is
also register for another system such as a third party newsletter scripts and
forum solutions.  Just activate and fill in the subscribe url and attributes
variables and your new users are automatically cross registered.
Version: 0.1 Author: Christopher Peacock Author
URI: http://free-web-site-tools.thegadgitech.com/aboutus
*/ ?>
< ?php
/*
     Copyright 2009
     Christopher Peacock
     (email : christopher.peacock@gmail.com)

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
?>
< ?php
add_action ( 'user_register', 'dualreg' );
function dualreg($dualreg_userid) {
     // CONFIGURE SETTINGS STARTING HERE 

     // form processor location (forms action attribute)
     // EXAMPLE FOR INFINITE RESPONDER
     // $dualreg_url = 'http://www.yourdomain.com/responder/s.php';
	$dualreg_url = '';

     // Is the form processor expecting GET attributes or POST attributes
     // GET = 0, POST = 1 	$dualreg_post = 1 ; 

     /* The way form submissions work is by sending the information to the
     above processor, using variable name and value pairs.*/ 

     // These variables define the variable names for the user name and email fields.
     $dualreg_emailn = 'e'; //user email variable name, iresponder uses e
     $dualreg_usern = 'f'; //user name variable name, iresponder uses f 

     // The remaining variables are added for additional information.
     // The variables used with Infinite Responder are here now, each
     // variable name has a comment after it, with the value set on the next line.
     // Empty variables will not be used.
     // Feel free to change name and value pairs to match your responder.
     $dualreg_attr1n = 'r'; // responder id
     $dualreg_attr1v = '4';
     $dualreg_attr2n = 'a'; // action, must be set to sub (subscribe)
     $dualreg_attr2v = 'sub';
     $dualreg_attr3n = 'ref'; // unknown, possibly referrer info in Infinite Responder stats
     $dualreg_attr3v = 'none';
     $dualreg_attr4n = 'h'; // are you sending HTML emails?
     $dualreg_attr4v = '1'; // 1 = yes, 0 = no
     $dualreg_attr5n = 'submit'; // must be equal to Submit for Infinite Responder
     $dualreg_attr5v = 'Submit';
     $dualreg_attr6n = 's'; // unknown, I think it does a "silent" subscription
     $dualreg_attr6v = '1';
     $dualreg_attr7n = ''; // the rest are blank and not used with Infinite Responder
     $dualreg_attr7v = '';
     $dualreg_attr8n = '';
     $dualreg_attr8v = '';
     $dualreg_attr9n = '';
     $dualreg_attr9v = ''; 

     // access username and email address from WordPress registration hook
     global $user_login , $user_email;
     get_currentuserinfo(); 

// This next section is commented out and will be used once a front-end
// administration menu is created.  I do not know how to build this yet,
// so if anyone would like to build the front-end, please post in the
// documentation area 

     // get variables set in admin
/*  $dualreg_url = get_option($dualreg_url);
     $dualreg_post = get_option($dualreg_post);
     $dualreg_namen = get_option($dualreg_namen);
     $dualreg_emailn = get_option($dualreg_emailn);
     $dualreg_attr1n = get_option($dualreg_attr1n);
     $dualreg_attr1v = get_option($dualreg_attr1v);
     $dualreg_attr2n = @get_option($dualreg_attr2n);
     $dualreg_attr2v = @get_option($dualreg_attr2v);
     $dualreg_attr3n = @get_option($dualreg_attr3n);
     $dualreg_attr3v = @get_option($dualreg_attr3v);
     $dualreg_attr4n = @get_option($dualreg_attr4n);
     $dualreg_attr4v = @get_option($dualreg_attr4v);
     $dualreg_attr5n = @get_option($dualreg_attr5n);
     $dualreg_attr5v = @get_option($dualreg_attr5v);
     $dualreg_attr6n = @get_option($dualreg_attr6n);
     $dualreg_attr6v = @get_option($dualreg_attr6v);
     $dualreg_attr7n = @get_option($dualreg_attr7n);
     $dualreg_attr7v = @get_option($dualreg_attr7v);
     $dualreg_attr8n = @get_option($dualreg_attr8n);
     $dualreg_attr8v = @get_option($dualreg_attr8v);
     $dualreg_attr9n = @get_option($dualreg_attr9n);
     $dualreg_attr9v = @get_option($dualreg_attr9v);
*/
     // create post/get variable
     $dualreg_vars = "$dualreg_emailn=$user_email";
     $dualreg_vars .= "&$dualreg_usern=$user_login";
     if($dualreg_attr2n != '') { $dualreg_vars .= "&$dualreg_attr1n=$dualreg_attr1v"; };
     if($dualreg_attr2n != '') { $dualreg_vars .= "&$dualreg_attr2n=$dualreg_attr2v"; };
     if($dualreg_attr3n != '') { $dualreg_vars .= "&$dualreg_attr3n=$dualreg_attr3v"; };
     if($dualreg_attr4n != '') { $dualreg_vars .= "&$dualreg_attr4n=$dualreg_attr4v"; };
     if($dualreg_attr5n != '') { $dualreg_vars .= "&$dualreg_attr5n=$dualreg_attr5v"; };
     if($dualreg_attr6n != '') { $dualreg_vars .= "&$dualreg_attr6n=$dualreg_attr6v"; };
     if($dualreg_attr7n != '') { $dualreg_vars .= "&$dualreg_attr7n=$dualreg_attr7v"; };
     if($dualreg_attr8n != '') { $dualreg_vars .= "&$dualreg_attr8n=$dualreg_attr8v"; };
     if($dualreg_attr9n != '') { $dualreg_vars .= "&$dualreg_attr9n=$dualreg_attr9v"; }; 

     // use variables to perform second registration
     if ($dualreg_post == 1) // this is a POST variables function
     {
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_MUTE, 1);
		curl_setopt($ch, CURLOPT_URL, $dualreg_url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $dualreg_vars);
		curl_exec ($ch);
		curl_close ($ch);
	} else { 			// this is a GET variable function
		$dualreg_geturl = "$dualreg_url?$dualreg_vars";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_MUTE, 1);
		curl_setopt($ch, CURLOPT_URL, $dualreg_geturl);
		curl_exec ($ch);
		curl_close ($ch);
	}
} // close dualreg function ?>

Version

0.2
-added comments and cleaned up code
-released to public
0.1
-initial functional project

Goals

  • interface to configure plugin
  • ability to import forms from different responders
  • clean up old code once above goals are met
  • submit to WordPress Plugin Directory

20 Responses to “WP Dual Registration – WordPress Plugin”

Comments (20)
  1. This is a key blog and I educe pleasure reading it every morning recriminate you
    becoming sharing it!

    louis vuitton handbags

  2. Cool plugin! Works great when I want to add subscribers to my own autoresponder as well, using the same form.

  3. If you encounter a problem when using this plugin with the Infinite Responder mail platform and WordPress registration succeeds but returns a 500 Internal Server Error, it is not a problem with this plugin. It is something in the subscription process on Infinite Responder. Most likely, your editing software added a blank line at the end of the config.php file and your getting the “headers already sent” error. Fix that and you should be good to go. Otherwise, maybe I can help you out with it, just ask. You can always download my modded version of Infinite Responder at Totally Free Web Site Tools.

  4. Hi, this plugin works owesome..but got some error at the end of confirmation page :

    Warning: Cannot modify header information – headers already sent by (output started at /home/myuser/public_html/domain/wp-content/plugins/wp-dual-registration.php:133) in /home/myuser/public_html/domain/wp-includes/pluggable.php on line 865

    Its ok, as long as it works for me. Thanks Christopher Peacock :)

    By the way, i’ve tryied to add another field such as firstname and lastname instead of just login name and email by default (I am using registerplus plugin), but it not work and my autoresponder can’t capture any information. What I do:

    add following variable after $dualreg_usern:
    $dualreg_fnamen = ‘da_fname’;
    $dualreg_lnamen = ‘da_lname’;

    add the following:
    global $user_login , $user_email, $first_name, $last_name;

    add this as well:
    $dualreg_vars .= “&$dualreg_fnamen=$first_name”;
    $dualreg_vars .= “&$dualreg_lnamen=$last_name”;

    Chris, do you have any idea to make this work? Thank you in advance..:)

  5. I’m happy to see my plugin is getting used! Thanks!

    The “headers already sent” error is most likely the other registration script displaying information, such as a confirmation page. You can confirm this by checking that line 133 is the curl_exec() line. The way I use it with Infinite Responder, the plugin submits to the second form silently, with nothing returned, so the user is sent to the WordPress registration complete page or redirected wherever Register Plus is set to send them. What is the other script you are using and I can see if there is a silent mode, like Infinite Responder has. Another possibility is a trailing blank line at the end of the plugin file. Make sure there is nothing after the closing php tag ( ?> ).

    For the first name and last name variables, they are stored in the usermeta table, and not the user table, which is what the get_currentuserinfo function retrieves. I haven’t tested this yet, but you could try adding this below the line that calls get_currentuserinfo (below since the user_id is needed):

    $first_name = get_usermeta($user_id, ‘first_name’);
    $last_name = get_usermeta($user_id, ‘last_name’);

    Also, I don’t think you need to set those as globals.

    Glad to help! Let me know how it turns out.
    -Chris

  6. Thanks Chris,

    For the “headers already sent” error, I notice that the confirmation page was the autoresponder’s page, eventhough I’ve set the attribute
    $dualreg_attr3n = ‘confirmationURL’ to some value in
    $dualreg_attr3r = ..com/wp-login.php?checkemail=registered.
    Is it required me to create another custom confirmation page since there are no silent option for the autoresponder?

    By the way, unluckily, autoresponder still return error “First name and Last name required”, means that they still can’t get the 1st and last name value using
    $first_name = get_usermeta($user_id, ‘first_name’);
    $last_name = get_usermeta($user_id, ‘last_name’);

    My idea is to get the 1st name and last name from $_POST value from cookies instead of pulling values from any table. Is it possible in WP?

  7. Sorry I haven’t responded before now. I’ve been really busy with other projects.

    The way it works, there should be no other confirmation page except the one set in Register Plus. Anything trying to display something else will cause the Headers already sent error, since both confirmation pages are trying to display at once. One of the features of cURL is the CURLOPT_MUTE option. It is already in the plugin code, but I don’t think it is working the way I thought it would. I’m going to run a few tests and see if there is a way to hide any output caused by the cURL function. Perhaps someone else has the answer to this dilemma. There are a few other cURL functions I have not tested. I will post my results later today.

  8. Yay! I found a workaround using an output buffer to suppress anything output by the function. The key functions to add are ob_start() and ob_end_clean(). They need to surround the cURL function, I surrounded the whole if/else block, as shown in the lines below:

    // use variables to perform second registration
    ob_start();
    if ($dualreg_post == 1) // this is a POST variables function
    {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $dualreg_url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $dualreg_vars);
    curl_exec ($ch);
    curl_close ($ch);
    } else { // this is a GET variable function
    $dualreg_geturl = "$dualreg_url?$dualreg_vars";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $dualreg_geturl);
    curl_exec ($ch);
    curl_close ($ch);
    }
    ob_end_clean();
    } // close dualreg function

    I will update the plugin download soon.

    Using this method, the cURL Mute option does not even need to be set. There may be another way of doing it with other cURL options, but I haven’t fully tested them yet. Since the output buffer seems to take care of everything, I may never test them. But for reference, I think these might be able to do something, but again I’m not sure:
    curl_setopt($ch, CURLOPT_MUTE, TRUE); // mutes all output? no, proven
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // returns output as return variable?
    curl_setopt($ch, CURLOPT_HEADER, FALSE); // stop from returning header?
    curl_setopt($ch, CURLOPT_NOBODY, TRUE); // stop from returning body?

  9. To answer the second part of the problem, you should be able to use the $_POST variables as usual. I actually didn’t even think about that, but using something like this should work:

    $first_name = $_POST['firstname'];
    $last_name = $_POST[‘lastname’];

  10. Looks like exactly what I’ve been looking for! Is the plugin still available? Download link above shows nothing found. Thanks much!

  11. Sorry about that, somehow the plugin file and even the directory it was in got deleted. It has been replaced. I’m not 100% on what state the plugin is in, I made changes, but I’m not sure if those changes were applied to only to my local copy, to the copy running on my site, or when the download here was last updated. If you have any problems, let me know and I will look into it.

  12. Do you think it is possible to integrate this with trafficwave? I’m not really good at code..

  13. some webhosting companies give free domains upon signing up with one of their plans .*-

  14. Yes, most hosting companies give a free domain for the life of the service when you pay annually instead of monthly. Generally, free domain name registration like this is limited to .com, .net and maybe a few other TLDs that are cheap. Otherwise, this domain name registration is usually around $10 per year.

    On a side note, I myself have partnered with a company in Houston, TX to provide a full service Web Design, Hosting, and SEO service, which offers this type of free domain name registration too. Find out more at TheNedBlurb.com and TNBhosting.com

  15. Sorry for the delayed response Tristan, I have been a little more busy these past few months.

    I am not familiar with trafficwave, but there is a good chance it will integrate. The plugin basically forwards the submitted information to a second processor, as if the user had filled out two similar forms and submitted them both. By taking the field names in the form code provided by trafficwave, and changing the relevant variables in the plugin, it should successfully submit the data to trafficwave. If the form code is simple enough, I could guide you or modify the plugin to suit trafficwave’s form fields. I do intend to make this type of integration easier in the future, but do not have the time or incentive to work on that for the moment. Let me know if you need further assistance.

  16. Hello! Someone in my Myspace group shared this site with us so I came to take a look. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers! Great blog and superb design.

  17. Hi! This is kind of off topic but I need some help from an established blog. Is it very hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about setting up my own but I’m not sure where to begin. Do

  18. Good day I am so grateful I found your weblog, I really found you by error, while I was browsing on Yahoo for something else, Anyways I am here now and would just like to say kudos for a fantastic post and a all round exciting blog (I also love the theme/d

  19. Great article, I just given this onto a co-worker who was doing a little research on that. And he in fact purchased me lunch because I discovered it for him

  20. Hello, i believe that i saw you visited my website thus i came to “return the prefer”.I’m attempting to in finding issues to enhance my web site!I assume its good enough to make use of a few of your ideas!!

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Ready to pay for services…

Blog Catalog
XHTML | CSS

Follow Me…

Twitter
On Twitter
(Web4Guru)

Christopher Peacock