• Is it possible to add custom fields to the subscription form? I think it would be very valuable to capture at least a name and/or additional information for newsletter subscriptions. Would love to see that feature become available soon. Or is it already possible to do that?

Viewing 15 replies - 1 through 15 (of 25 total)
  • It’s already possible. Go to Users and select one of the users. Once you’re on that page you can add a custom field.

    To add the info of that custom field in your email template use $args->your_data (see the api page on the mailpress website for more info).

    Thread Starter rajaman

    (@rajaman)

    Thank you for your answer.
    What I am looking for is to add a custom field to the subscription form. So that, for example, users are required to provide a name along with the email when they sign up. Do you know if that is already possible?

    I second that notion for at least the first name in the widget subscription form. Thanks in advance ??

    To be quite honest: I have no idea, but I don’t think so (you can only change title and subscription button text in widget). Would be a nice feature to add though.

    yepp. the custom fields plugin only allows the admin adding custom fields, which is pretty useless as I too want the subscriber to add his name, or i.e. check SMS/Email depending on how he wants to receive the newsletter…

    Well, there is a way to use custom fields, but it’s not built-in with MP (theoretically it should work).

    With MP you can select the option to synchronize MP with the WP users (you can activate the option to subscribe to the newsletter in the registration form). With Register Plus you can add multiple custom fields to the profile a/o registration form.

    So, in theory, you should be able to use those custom fields in your newsletters (haven’t tested it out though).

    can’t seem to find these options:

    With MP you can select the option to synchronize MP with the WP users (you can activate the option to subscribe to the newsletter in the registration form).

    can you give me a hint how to do that?

    btw. its not necessarily about using those custom fields in the newsletter, though that would be a nice touch, but more about knowing who signs up for that newsletter and some other options: i.e. a checkbox to let the user select in which language he wants the newsletter

    You can download the additional module from MailPress (AddOns – MailPress_sync_wordpress_user’. Forgot to mention that, sorry.

    ok, this solution looks promising, but the documentation is very scarce ??

    – what does this option mean: Allow subscriptions from: Registration Form – I can check this but what does it do?
    – should I create the special fields from within Register Plus of within the custom fields add on for mailpress?

    The check is that you allow users to subscribe to a/your newsletter when they are registering on the site.
    You should create the special fields from within Register Plus.

    We need to get this feature put natively into Mailpress, because even if this “Register Plus” workaround works (does it?) we still won’t have the ability to filter large user lists by our custom fields, which is the whole point I think, so you can sort and send a newsletter to just the people that fit a certain demographic. (For me I want to be able to send mail just to people in a certain state to notify the people when my band is coming to play there.

    jepp, right. now only if the author of MP would give us an official statement ??

    I second the desire to have a name along with the email on the subscription form. I’ve designed up the subscription form for my client and I guess I can ignore the name field for now, but it would be nice if it served a purpose. :-/

    I also needed this for a client. So I hobbled together a hack. Here it is. You’ll have to update 2 files: mailpress/mp-includes/class/MP_Widget.class.php and mailpress/mp-includes/class/MP_User.class.php.

    In MP_Widget.class.php look for “<!– start of code generated by MailPress –>” it’s around line 108. You’ll find the form there. It currently just have the email input field, but I added a first and last name fields, and a zip code field. The names of the fields were ‘first’,’last’,and ‘zip’ respectively. I basically just copied the current email code and just changed the variables and names.

    <input class='MailPressFormEmail' type='text' name='email' value="<?php echo $email; ?>" size='25' onfocus="if(this.value=='<?php echo js_escape($options['txtfield']); ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo js_escape($email); ?>';" />
    <input class='MailPressFormEmail' type='text' name='first' value="<?php echo $first; ?>" size='25' onfocus="if(this.value=='<?php echo js_escape($options['txtfield']); ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo js_escape($first); ?>';" />
    <input class='MailPressFormEmail' type='text' name='last' value="<?php echo $last; ?>" size='25' onfocus="if(this.value=='<?php echo js_escape($options['txtfield']); ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo js_escape($last); ?>';" />
    <input class='MailPressFormEmail' type='text' name='zip' value="<?php echo $zip; ?>" size='25' onfocus="if(this.value=='<?php echo js_escape($options['txtfield']); ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo js_escape($zip); ?>';" />

    Then find this code around line 170ish:
    “$email = ( isset($_POST[’email’]) ) ? $_POST[’email’] : ”;”
    and replicate this line for each of your extra fields, mine looked like this:

    $email = ( isset($_POST['email']) ) ? $_POST['email'] : '';
    $first = ( isset($_POST['first']) ) ? $_POST['first'] : '';
    $last = ( isset($_POST['last']) ) ? $_POST['last'] : '';
    $zip = ( isset($_POST['zip']) ) ? $_POST['zip'] : '';

    A few more lines down find the if statement that checks to see if the fields are filled out:
    “if ( ” == $email || $defaults[‘txtfield’] == $email )”
    and add the extra fields to the if statement, mine looked like this:
    if ( '' == $email || $defaults['txtfield'] == $email || '' == $first || '' == $last || '' == $zip )
    And finally for the Widgets class page, find this:
    “$add = MP_User::add($email);” and change to:

    $add = MP_User::add($email,$first,$last,$zip);

    .

    Now let’s go to the MP_User.class.php file. Around line 362, find “public static function add($email){” and add in your extra field’s variables. Mine looked like this:
    “public static function add($email,$first,$last,$zip) {“.
    Finally, find the if statement around line 400 that says “if ( self::insert($email, $key) )” and add your extra fields like this:

    if ( self::insert($email, $key) )
    					{
    						MP_Usermeta::add(self::get_id_by_email($email),'First',$first);
    						MP_Usermeta::add(self::get_id_by_email($email),'Last',$last);
    						MP_Usermeta::add(self::get_id_by_email($email),'Zip',$zip);
    						$return['result']  = true;
    						$return['message'] = $defaults['txtwaitconf'] ;
    						return $return;
    					}

    Save and upload. These changes should then change the functionality of your form so that when a user initially signs up, their record will also be given custom fields generated from your form. Hope this helps!

    sounds good, would you mind notifying the author? maybe he’ll build it in?

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘[Plugin: MailPress] Custom fields for subscription form’ is closed to new replies.