WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: MailPress] Custom fields for subscription form (26 posts)

  1. rajaman
    Member
    Posted 5 years ago #

    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?

  2. Hiranthi
    Member
    Posted 5 years ago #

    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).

  3. rajaman
    Member
    Posted 5 years ago #

    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?

  4. masterbassie
    Member
    Posted 5 years ago #

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

  5. Hiranthi
    Member
    Posted 5 years ago #

    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.

  6. Ovidiu
    Member
    Posted 5 years ago #

    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...

  7. Hiranthi
    Member
    Posted 5 years ago #

    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).

  8. Ovidiu
    Member
    Posted 5 years ago #

    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

  9. Hiranthi
    Member
    Posted 5 years ago #

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

  10. Ovidiu
    Member
    Posted 5 years ago #

    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?

  11. Hiranthi
    Member
    Posted 5 years ago #

    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.

  12. brotherjoseph
    Member
    Posted 5 years ago #

    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.

  13. Ovidiu
    Member
    Posted 5 years ago #

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

  14. jmsrmk
    Member
    Posted 5 years ago #

    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. :-/

  15. davelassanske
    Member
    Posted 4 years ago #

    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!

  16. Ovidiu
    Member
    Posted 4 years ago #

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

  17. davelassanske
    Member
    Posted 4 years ago #

    I will try and get in touch with the author - the mailpress.org site seems to be having some difficulties at the moment though.

  18. jeffcirceo
    Member
    Posted 4 years ago #

    Thanks for the code just what I was looking for.

  19. Tibor Paulsch
    Member
    Posted 4 years ago #

    @davelassanske: I have been looking on how to do this too; so thanks a lot!

    I haven't tried your hack yet, but was wondering if the extra form fields also will be available on the subscriber's "manage subscription" page?

  20. priamlodyssey
    Member
    Posted 4 years ago #

    @davelassanske I've setup you hack as described, seems to work but I'm unable to view the custom fields (in my case "Country" & "City") in the back-end, is there a way to show the fields in the "MailPress Users" section?

  21. Ovidiu
    Member
    Posted 4 years ago #

    still no feedback from the plugin author :-( I am really unsure if I should use this plugin or search for another alternative...

    anyone knows another newsletter plugin with the following features:

    - allow double opt-in
    - allow collection of additional user details i.e. cell number, age, sex, preferred method of communication
    - allows me to customize the newsletter which by the way won't/shouldn't contain content from the blog buyt rather hand crafted news
    - can handle i.e. 3000 subscribers...

    I think that is all...

  22. Jandal
    Member
    Posted 4 years ago #

    Awesome!

    @davelassanske thanks for the hack to the front end, gave a HUGH head start into making this thing work.

    @priamlodyssey and anyone else wanting the back end hack follow along

    I recommend activating the plugin
    "mailpress_user_custom_fields"
    as this will allow you to edit the custom fields we have entered with out having to do the following code hack. But if you want nice fancy organised rows with custom info then carry on...

    How to show those custom fields in the back end in a nice way
    edit the page
    mailpress\mp-includes\class\MP_User.class.php

    *The following will vary depending on your personal situation*
    Find line 867 switch ($column_name)
    You will need to enter a "case" into the "switch" statement depending on your custom fields.

    My "case" looked like this

    case 'firstname' :
    					$metas = MP_Usermeta::get($mp_user->id);
    
    					if ($metas) {
    						if (!is_array($metas)) $metas = array($metas);
    
    						foreach ($metas as $meta) {
    							if ($meta->meta_key[0] == '_') continue;
    
    							if ($meta->meta_key == 'FirstName')
    								$firstname = $meta->meta_value;
    						}
    					}
    ?>
    		<td  <?php echo $attributes ?>>
    			<abbr title="<?php echo $firstname; ?>"><?php echo $firstname; ?></abbr>
    		</td>
    <?php
    				break;

    You can see the names and values of your meta data by editing the a Mailpress user.

    I know there is not a heap of detail but it should be enough for those who have done the first hack. The trick here was pulling the meta data out.

    HTH
    =-)

  23. RENAUT
    Member
    Posted 4 years ago #

    new release: MailPress 4.0.1
    new documentation : http://www.mailpress.org
    a forum : http://groups.google.com/group/mailpress

  24. inspired888
    Member
    Posted 4 years ago #

    @arena: Are you implying that this latest release resolves this custom fields issue? Or are you just randomly posting that info to a non-related thread? If 4.01 sorts this issue out (provides this feature) I'll be very happy.

  25. inspired888
    Member
    Posted 4 years ago #

    Hi folks,
    I see that the above hack/solution requires the use of Register Plus. I note that RP is considered compatible only to WP v.2.6
    Is anyone using it successfully on WP 2.8.x ?

  26. mhewes
    Member
    Posted 4 years ago #

    i am using WordPress 2.8.6 with Register Plus and it works great.

Topic Closed

This topic has been closed to new replies.

About this Topic