Page 1 of 1

Separate Billing name and Username

PostPosted: September 12th, 2011, 1:54 pm
by MODassic
Hello, I have a client that has determined that the checkout process must have a way for users to fill out a billing name that is unrelated to the name of the account. This seems like a question that you guys may have encountered before, I can't find any references to it, but I was hoping you had some advice.

We are using the auth.net gateway, and I have already copied the forms.html into my theme directory to customize those fields, but I am a little confused on how to seperate the name out, I can create the fields, but I'm not sure where to go to non destructively edit how those fields are processed.

Any response would be appreciated, even if its a, you cant do that, or thats going to take serious work.

Thanks,
-Taylor

Re: Separate Billing name and Username

PostPosted: September 12th, 2011, 7:28 pm
by Bruce C
That doesn't sound too complicated, as I think WordPress has a feature to handle this (Nickname).

However, before you start coding, try playing around with the settings under Dashboard -> s2Member -> General Options -> Custom Registration Fields/Options -> Set "Display Name" during Registration?

I think that the setting "Yes (set Display Name to User's Username)" or "No" Might work for you.

Cheers!

Re: Separate Billing name and Username

PostPosted: September 26th, 2011, 2:48 pm
by Cristián Lávaque
Would custom registartion fields work for you to do this? WP Admin -> s2Member -> General Options -> Custom Registration -> Add New Field

Re: Separate Billing name and Username

PostPosted: September 26th, 2011, 3:05 pm
by MODassic
We are already using those, this is something separate. Say a minor want to sign up and use their parents card, we want to split up name and billing name to make that possible without having to go back and change things after checkout.

Re: Separate Billing name and Username

PostPosted: September 28th, 2011, 3:42 am
by Cristián Lávaque
I emailed Jason asking him about this.

Re: Separate Billing name and Username

PostPosted: September 28th, 2011, 9:36 am
by MODassic
thanks

Re: Separate Billing name and Username

PostPosted: October 1st, 2011, 9:28 pm
by Jason Caldwell
Yes, this is possible, but it's not super simple.

FYI: s2Member has no restriction that absolutely says the Billing Name MUST be the same as what's on the card. But if you really want to differentiate the two, feel free to continue with these instructions.

First, you will need to create a Custom Registration Field with s2Member that collects a separate name during checkout. A name that will be used on the actual Membership account, since you want that to be differentiated.

Now, create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
( this will handle post-processing of your Custom Registration Field, assuming it's ID is `child_name` )
Code: Select all
<?php
add_action 
("ws_plugin__s2member_during_configure_user_registration_front_side", "my_custom_name_handler");
function my_custom_name_handler ($vars = array ())
    {
        if (($user_id = $vars["user_id"]) && !empty ($_POST["s2member_pro_authnet_checkout"]["custom_fields"]["child_name"]))
            {
                // Get full name of Child, this will be used on the account.
                $full_display_name = esc_html ($_POST["s2member_pro_authnet_checkout"]["custom_fields"]["child_name"]);
                // Break full name apart at the first space in the full name, to get a first/last name.
                list ($first_name, $last_name) = preg_split ("/ +/", $full_display_name, 2);
                // Update this new account, using the name that I collected with Custom Reg Field ID: `child_name`.
                wp_update_user (array ("ID" => $user_id, "first_name" => $first_name, "last_name" => $last_name, "display_name" => $full_display_name));
            }
    }
?>
See also: http://codex.wordpress.org/Function_Ref ... pdate_user