CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Need to collect Home email address AND Work email on a membership signup form
Pages: [1]

Author Topic: Need to collect Home email address AND Work email on a membership signup form  (Read 914 times)

jimmyjam

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 4
Need to collect Home email address AND Work email on a membership signup form
May 03, 2010, 09:48:34 pm
Hi,

I created a contribution page for membership registration and renewal. On this page, I need to collect Home email address AND Work email address. Unfortunately, the contribution page's built-in "Email Address" field is silencing the email address fields on a custom profile that's linked to the page. Therefore, I can't collect either the Home email address or the Work email address.

Does anyone have any suggestions on overcoming this challenge?

Thanks,
James

Rahul Bile

  • I post occasionally
  • **
  • Posts: 112
  • Karma: 16
  • impossible says, I M Possible
    • I AM POSSIBLE
Re: Need to collect Home email address AND Work email on a membership signup form
May 04, 2010, 12:17:52 am
Hello james,

On contribution page, we unset all the email fields ( coming through profile ), as email field already exists on contribution Page.
Below patch will allow the work email address field on contribution page added through profile.

Index: CRM/Contribute/Form/ContributionBase.php
===================================================================
--- CRM/Contribute/Form/ContributionBase.php   (revision 27395)
+++ CRM/Contribute/Form/ContributionBase.php   (working copy)
@@ -704,8 +704,12 @@
 
             if ( $fields ) {
                 // unset any email-* fields since we already collect it, CRM-2888
+                // Get the "Work" location type id and do not unset the Work email.
+                require_once "CRM/Core/PseudoConstant.php";
+                $locationTypes = CRM_Core_PseudoConstant::locationType( );
+                $workEmailId = array_search( 'Work', $locationTypes );
                 foreach ( array_keys( $fields ) as $fieldName ) {
-                    if ( substr( $fieldName, 0, 6 ) == 'email-' ) {
+                    if ( substr( $fieldName, 0, 6 ) == 'email-' && $fieldName != 'email-'.$workEmailId ) {
                         unset( $fields[$fieldName] );
                     }
                 }

Hope this helps.

Rahul.
Consider donating to CiviCRM if you use it. http://civicrm.org/donate

jimmyjam

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 4
Re: Need to collect Home email address AND Work email on a membership signup form
May 12, 2010, 02:59:46 am
Thanks Rahul!  I'll give it a try.

-James

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Need to collect Home email address AND Work email on a membership signup form

This forum was archived on 2017-11-26.