I think I solved it. Gonna give it another try.
EDIT:
It did not work, I tried using javascript to fill in values. But looks like the email and zip code needs to be filled in via keyboard interaction.
I just need to disable or change it to a different one instead of .keyup().
EDIT2:
I have found the problem.
add_action ("ws_plugin__s2member_pro_before_sc_authnet_form", "s2_customize_pro_form", 1000);
function s2_customize_pro_form ($vars = array())
{
/* Don't pre populate when/if the Pro Form has just been POSTd, and/or if it's a Modification Form
with modify="1", because s2Member already pre populates Pro Forms in that scenario, with the
User's existing Email and Username. */
if(empty ($_POST["s2member_pro_authnet_checkout"]) && empty($vars["attr"]["modify"])) {
?>
<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. */
{
/* Generate random number to append to username,
hopefully making it unique (yes, this isn't perfect!) */
var randomNum = Math.ceil(Math.random()*999);
if($('input#s2member-pro-authnet-checkout-email').length) {
var email = 'input#s2member-pro-authnet-checkout-email';
var login = 'input#s2member-pro-authnet-checkout-username';
$('#s2member-pro-authnet-checkout-form-username-div').hide();
} else {
var email = 'input#s2member-pro-authnet-registration-email';
var login = 'input#s2member-pro-authnet-registration-username';
$('#s2member-pro-authnet-registration-form-username-div').hide();
}
/* 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());
});
$(login).val ($.trim ($ (email).val ().split (/@/)[0].replace (/[^\w]/gi, '')) + randomNum.toString());
});
}) (jQuery);
</script>
<?php
}
}
I have put $(login).val ($.trim ($ (email).val ().split (/@/)[0].replace (/[^\w]/gi, ”)) + randomNum.toString()); outside the hack provided before.
http://www.s2member.com/forums/topic/make-username-field-optional-and-hide-it/
I forgot I implemented this hack 1-3 months ago.
Thanks a lot! S2member