Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Ariel Kanevsky

    (@askanevsky)

    I decided to make a child Twenty Seventeen theme and modified header.php. Seems like adding a !is_singular('give_forms') clause to line 49 did the trick – “display the featured picture unless the page is a Give donation form”.

    David – I could give it a shot. I know this is a heavily requested feature. My time, like everyone else’s, is limited.

    Chris – that is NOT generalized code. It works in my specific instance however draws on techniques that should be transferable. If you’re just hoping to alter the one form on the single URL, I could do it for you if you grant me access, however, as David mentioned, updating the plugin will erase the customization.

    I think I may be the user that David was referring to. I am no longer using JavaScript to set default funds – I have moved the logic to seamless-donations-form.php. It’s a more robust technique, I just need to be careful when updating the plugin, otherwise my customizations are lost. For example, I have two types of donation pages…

    https://www.r4wh.org/donate/

    and

    https://www.r4wh.org/team-r4wh/2016-riders/ian-downs/

    With the /donate page, the checkbox that reveals the fund dropdown is pre-selected and hidden – it’s obvious to the user to look for a specific fund. The user is not forced to choose a fund, but encouraged with greater visibility.

    With the /team-r4wh/2016-riders/ian-downs page, the fund is pre-selected for the user and cannot be modified – the fields are hidden but submitted with the form. In this example, the “Ian Down’s Ride” fund is pre-selected – this seems reasonable as the user is donating form Ian Down’s page.

    I would imagine you’re looking for this type of functionality and if you feel comfortable playing around with the PHP, it’s not that difficult. Here’s a bit of my custom code that should illustrate the important part.

    // Designated Funds
    
    	if( get_option ( 'dgx_donate_show_designated_funds_section' ) == 'true' ) {
    		// in 4.0+ funds are a custom post type, not an option array
    
    		$query_args  = array(
    			'orderby'     => 'title',
    			'order'       => 'asc',
    			'post_type'   => 'funds',
    			'post_status' => 'publish',
    			'numberposts'   => -1,
    			'meta_query'  => array(
    				array(
    					'key'   => '_dgx_donate_fund_show',
    					'value' => 'Yes',
    				)
    			)
    		);
    		$posts_array = get_posts ( $query_args );
    
    		$fund_count = count ( $posts_array );
    
    		if( $fund_count > 0 ) {
    
    			$options_array = array(
    				0 => 'No rider specified',
    			);
    
    			foreach( $posts_array as $post ) {
    				$title                = $post->post_title;
    				$id                   = $post->ID;
    				$options_array[ $id ] = $title;
    			}
    
    			// Hack by Ariel Kanevsky in order to pre-select riders on rider pages
    			$url_fields = array_filter(explode('/', $_SERVER['REQUEST_URI']));
    			if (!ctype_alpha(substr(end($url_fields), 0, 1))) {
                            	// URL likely ends in some arguments, chop them off
                            	array_pop($url_fields);
    			}
    			$rider = str_replace('-', ' ', end($url_fields));
    			// Rider funds should be named following a "John Doe's Ride" convention
    
    			if ($matched_rider = preg_grep("/^$rider/i", $options_array)) {
    				// We're at a rider's page, set input values accordingly
    				$funds_section = array(
    					'elements' => array(
    						'_dgx_donate_designated_fund' => array(
    							'type'    => 'hidden',
    							'value' => esc_attr(key($matched_rider))
    						),
    					),
    				);
    			} elseif (($rider == 'donate') || ($rider == 'alumni')) {
    				// We're at the general donation page, set input values accordingly
    				$donation_section['elements']['_dgx_donate_designated'] = array(
    					'type'   => 'checkbox',
    					'id'     => 'dgx-donate-designated',
    					'select' => true,
    					'prompt' => esc_html__ ("I would like to designate this donation to a specific fund", 'seamless-donations'),
    					'style' => 'display:none'
    				);
    				$funds_section = array(
    					'elements' => array(
    						'designated_fund_label' => array(
    							'type'  => 'static',
    							'value' => esc_html__ ( 'I would like my donation to be credited towards the following rider\'s fundraising goal:', 'seamless-donations' ) . " ",
    						),
    						'_dgx_donate_designated_fund' => array(
    							'type'    => 'select',
    							'class'   => '',
    							'options' => $options_array,
    						),
    					)
    				);
    				if ($rider == 'alumni') {
    					// We're at the alumni donation page, set monthly donations and change the values
    					$repeating_section = array(
    						'elements' => array(
    							'_dgx_donate_repeating' => array(
    								'type' => 'hidden',
    								'value' => true,
    								'id' => 'dgx-donate-repeating',
    							)
    						)
    					);
    					$donation_section['repeating_section'] = $repeating_section;
    					// assemble the radio buttons for the giving levels
            				$giving_levels = dgx_donate_get_giving_levels();
    					foreach ($giving_levels as $giving_level) {
    						unset($donation_section['elements']["dgx_donate_giving_level_$giving_level"]);
    					}
    					unset($giving_level_key, $giving_level_option, $formatted_amount, $element);
    					unset($donation_section['elements']['other_radio_button']);
    					unset($donation_section['elements']['_dgx_donate_user_amount']);
    					$giving_levels = array(
    						'supporter' => 5,
    						'intern' => 10,
    						'resident' => 25,
    						'attending' => 50,
    						'chair' => 100
    					);
    					$per_month_suffix = ' per month <br />';
    					foreach ($giving_levels as $training_level => $giving_level) {
    						$giving_level_key = "dgx_donate_giving_level_" . $giving_level;
    						$per_month_prefix = ucfirst(str_replace('_', ' ', $training_level)) . ' - ';
    						if ($training_level == 'chief') {
    							$per_month_suffix = $per_month_suffix . '<br />';
    						}
    						$formatted_amount = $per_month_prefix . seamless_donations_get_escaped_formatted_amount($giving_level, 0) . $per_month_suffix;
    						$element = array(
    							'type'    => 'radio',
    							'group'   => '_dgx_donate_amount',
    							'wrapper' => 'span',
    							'value'   => $giving_level,
    							'prompt'  => $formatted_amount,
    						);
    						$donation_section['elements'][$giving_level_key] = $element;
    					}
    				}
    			}
    			$donation_section['funds_section'] = $funds_section;
    		}
    	}
Viewing 3 replies - 1 through 3 (of 3 total)