Community Support Forums — WordPress® ( Users Helping Users ) — 2011-10-30T00:46:57-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=15672 2011-10-30T00:46:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15672&p=50430#p50430 <![CDATA[Re: User registration without username]]>

Statistics: Posted by Cristián Lávaque — October 30th, 2011, 12:46 am


]]>
2011-10-28T13:15:53-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15672&p=49084#p49084 <![CDATA[Re: User registration without username]]> Nice work! Thanks for sharing this.
~ Updated rank to Experienced User.

Statistics: Posted by Jason Caldwell — October 28th, 2011, 1:15 pm


]]>
2011-10-28T13:08:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15672&p=49082#p49082 <![CDATA[Re: User registration without username]]>
Jason Caldwell wrote:
Please see this thread. I built a custom hacks file that will accomplish this, and it seems to be working well for others. Goto: viewtopic.php?f=36&t=14806&p=33812#p33812


Jason, that's brilliant -- thanks!

I've modified your script slightly to hide the username field and append a randomly generated number to the username (to reduce the chances of a user registering with a conflicting username; as noted in the code comments, this isn't a fool-proof solution.) I also hid some other elements that I didn't want to show on the registration page.

Image

For those looking to create a registration form with the username field hidden and the username automatically generated, here you go:

Create this directory and file:
/wp-content/mu-plugins/email-to-username.php
Code:

<?php
add_action 
("login_head", "s2_customize_login", 1000);
function s2_customize_login ()
    {
?>
        <script type = "text/javascript">
        function getParameterByName(name)
        {
          name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
          var regexS = "[\\?&]" + name + "=([^&#]*)";
          var regex = new RegExp(regexS);
          var results = regex.exec(window.location.href);
          if(results == null)
            return "";
          else
            return decodeURIComponent(results[1].replace(/\+/g, " "));
        }

            (function ($) /* Wraps this `$ = jQuery` routine. */
                {
                    $.fn.swapWith = function (to) /* Utility extension for jQuery. */
                        {
                            return this.each (function ()
                                {
                                    var $to = $ (to).clone (true), $from = $ (this).clone (true);
                                    $(to).replaceWith ($from), $ (this).replaceWith ($to);
                                });
                        };
                    /**/
                    $(document).ready (function () /* Handles email-to-username on keyup. */
                        {    
                         /* If this is the register page, customize it */
                         if(getParameterByName('action') == 'register'){
    
                                /* Generate random number to append to username, 
                                hopefully making it unique (yes, this isn't perfect!) */
                                var randomNum = Math.ceil(Math.random()*999);

                                var email = 'input#user_email';
                                var login = 'input#user_login';
                                var firstname = 'input#ws-plugin--s2member-custom-reg-field-first-name';
                                var lastname = 'input#ws-plugin--s2member-custom-reg-field-last-name';
    
                                $('p.message').hide();
                                $('div.ws-plugin--s2member-custom-reg-field-divider-section').hide();
                                $('#reg_passmail').hide();
                                $('#nav').hide();
                                $('#wp-submit').val('Subscribe');
                                $(login).closest ('p').hide();
                                
                                $(email).closest ('p').swapWith ($ (firstname).closest ('p'));
                                $(email).closest ('p').swapWith ($ (lastname).closest ('p'));
                                $(firstname).focus();
                                $(email).attr('tabindex', 50);
                                /* Fill hidden username field with first part of email address
                                    and append randomNum to hopefully make it unique. */
                                $ (email).keyup (function ()
                                    {
                                        $(login).val ($.trim ($ (email).val ().split (/@/)[0].replace (/[^\w]/gi, '')) + randomNum.toString());
                                    });                                
                }
                        });
                }) (jQuery);
        </script>
<?php
    
}
?>



(This is based on Jason's version here: viewtopic.php?f=36&t=14806&p=33812#p33812)

Note that I also hid a few other elements on the page. You can delete those lines if you don't want to hide those elements.

Statistics: Posted by Raam Dev — October 28th, 2011, 1:08 pm


]]>
2011-10-27T16:43:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15672&p=49007#p49007 <![CDATA[Re: User registration without username]]> Please see this thread. I built a custom hacks file that will accomplish this, and it seems to be working well for others. Goto: viewtopic.php?f=36&t=14806&p=33812#p33812

Statistics: Posted by Jason Caldwell — October 27th, 2011, 4:43 pm


]]>
2011-10-27T16:06:02-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15672&p=49003#p49003 <![CDATA[Re: User registration without username]]> http://wordpress.org/extend/plugins/wp-email-login/

Statistics: Posted by Cristián Lávaque — October 27th, 2011, 4:06 pm


]]>
2011-10-26T18:42:52-05:00 http://www.primothemes.com/forums/viewtopic.php?t=15672&p=48910#p48910 <![CDATA[User registration without username]]>
I use s2Member primarily for the Paypal -> AWeber integration. I'm creating a subscription-based email offering that requires my readers to subscribe via Paypal to receive premium email content. Once they pay through Paypal, s2Member automatically adds them to my AWeber email list so they receive my premium email content.

I'm trying to make this process as simple as possible for my readers. Since it's an email-based offering, they have no reason to login to my WordPress site. I don't mind the accounts being created for s2Member to handle Subscription Cancellations, etc., however when the registration form is presented to them they're required to enter a "Username", which adds confusion to the process.

I understand that WordPress requires a username to create their account, so I'm wondering if there's any way to automatically generate a username (perhaps based on their email address) and then hide that field on the registration form so that all they see is Email Address, First Name, and Last Name.

Any ideas?

Statistics: Posted by Raam Dev — October 26th, 2011, 6:42 pm


]]>