Statistics: Posted by Cristián Lávaque — October 30th, 2011, 12:46 am
Statistics: Posted by Jason Caldwell — October 28th, 2011, 1:15 pm
<?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
}
?>
Statistics: Posted by Raam Dev — October 28th, 2011, 1:08 pm
Statistics: Posted by Jason Caldwell — October 27th, 2011, 4:43 pm
Statistics: Posted by Cristián Lávaque — October 27th, 2011, 4:06 pm
Statistics: Posted by Raam Dev — October 26th, 2011, 6:42 pm