Title: [Plugin: MailPress] Custom fields for subscription form
Last modified: August 19, 2016

---

# [Plugin: MailPress] Custom fields for subscription form

 *  [rajaman](https://wordpress.org/support/users/rajaman/)
 * (@rajaman)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/)
 * 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)

1 [2](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/page/2/?output_format=md)

 *  [Hiranthi](https://wordpress.org/support/users/illutic/)
 * (@illutic)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020571)
 * 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](http://mailpress.org) website for more info).
 *  Thread Starter [rajaman](https://wordpress.org/support/users/rajaman/)
 * (@rajaman)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020854)
 * 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?
 *  [masterbassie](https://wordpress.org/support/users/masterbassie/)
 * (@masterbassie)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020855)
 * I second that notion for at least the first name in the widget subscription form.
   Thanks in advance 🙂
 *  [Hiranthi](https://wordpress.org/support/users/illutic/)
 * (@illutic)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020876)
 * 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.
 *  [Ovidiu](https://wordpress.org/support/users/ovidiu/)
 * (@ovidiu)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020877)
 * 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…
 *  [Hiranthi](https://wordpress.org/support/users/illutic/)
 * (@illutic)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020886)
 * 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).
 *  [Ovidiu](https://wordpress.org/support/users/ovidiu/)
 * (@ovidiu)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020887)
 * 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
 *  [Hiranthi](https://wordpress.org/support/users/illutic/)
 * (@illutic)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020888)
 * You can download the additional module from [MailPress](http://www.mailpress.org/)(
   AddOns – MailPress_sync_wordpress_user’. Forgot to mention that, sorry.
 *  [Ovidiu](https://wordpress.org/support/users/ovidiu/)
 * (@ovidiu)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020890)
 * 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?
 *  [Hiranthi](https://wordpress.org/support/users/illutic/)
 * (@illutic)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020891)
 * 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.
 *  [brotherjoseph](https://wordpress.org/support/users/brotherjoseph/)
 * (@brotherjoseph)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020919)
 * 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.
 *  [Ovidiu](https://wordpress.org/support/users/ovidiu/)
 * (@ovidiu)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020923)
 * jepp, right. now only if the author of MP would give us an official statement
   😉
 *  [jmsrmk](https://wordpress.org/support/users/jmsrmk/)
 * (@jmsrmk)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020927)
 * 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. :-/
 *  [davelassanske](https://wordpress.org/support/users/davelassanske/)
 * (@davelassanske)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020938)
 * 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!
 *  [Ovidiu](https://wordpress.org/support/users/ovidiu/)
 * (@ovidiu)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/#post-1020939)
 * sounds good, would you mind notifying the author? maybe he’ll build it in?

Viewing 15 replies - 1 through 15 (of 25 total)

1 [2](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/page/2/?output_format=md)

The topic ‘[Plugin: MailPress] Custom fields for subscription form’ is closed to
new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [subscription form](https://wordpress.org/support/topic-tag/subscription-form/)

 * 25 replies
 * 14 participants
 * Last reply from: [mhewes](https://wordpress.org/support/users/mhewes/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-mailpress-custom-fields-for-subscription-form/page/2/#post-1020998)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
