Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I will try and get in touch with the author – the mailpress.org site seems to be having some difficulties at the moment though.

    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!

Viewing 2 replies - 1 through 2 (of 2 total)