Adding special requests to events sign-up

Hi,

Is it possible, to add a step to the process of attending a event , where the user can have a free-form text field for special requests? This would then get emailed to the event organizer.

We would also like the event organizer to be able to go back into the event and be able to view the special requirements.

If you have any ideas/code examples that would be great.

Thanks

  • Ash

    Hello @Michelle

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    This won't be possible out of the box. I have an idea though.

    How's about showing a textarea in the single event page and when an user write something there and click on I am attending, this will be saved and could be shown in the edit event page by the admin. How does that sound to you?

    Cheers
    Ash

  • Ash

    Hello @Michelle

    You can try this code: https://gist.github.com/bappi-d-great/7a1c9fe08d371612d9b9

    The code is the following:

    add_filter( 'eab-rsvps-button-no', 'get_req_form', 10 );
    function get_req_form( $content ){
    	if( is_user_logged_in() )
    		$form = '<div class="sp_req_wrap"><textarea name="sp_req" placeholder="Special Request"></textarea></div>';
    	else
    		$form = '';
    	return $form . $content;
    }
    
    add_action( 'wp_footer', 'events_req_style' );
    function events_req_style() {
    	?>
    	<style>
    	.sp_req_wrap{
    		margin: 20px 0;
    	}
    	.sp_req_wrap, .sp_req_wrap textarea{
    		width: 95%;
    		height: 100px;
    	}
    	.wpmudevevents-buttons{
    		float: none !important;
    	}
    	</style>
    	<?php
    }
    
    add_action( 'incsub_event_booking_yes', 'incsub_event_booking_yes_cb', 20, 2 );
    function incsub_event_booking_yes_cb( $event_id, $user_id ) {
    	$temp = get_post_meta( $event_id, 'sp_req', true );
    
    	if( ! is_array( $temp ) ) $temp = array();
    
    	$temp[] = array(
    		      'user_id' => $user_id,
    		      'sp_req' => $_POST['sp_req']
    		      );
    
    	update_post_meta( $event_id, 'sp_req', $temp );
    
    }
    
    add_action( 'add_meta_boxes', 'ev_add_meta_box' );
    function ev_add_meta_box() {
    	add_meta_box(
    			'ev_sp_req',
    			'Special Requests',
    			'sp_req_callback',
    			'incsub_event',
    			'advanced',
    			'high'
    		);
    }
    
    function sp_req_callback( $post ) {
    	$reqs = get_post_meta( $post->ID, 'sp_req', true );
    
    	$html = '<table cellpadding="5" cellspacing="5" width="100%">';
    	$html .= '<tr>';
    	$html .= '<th width="20%" style="text-align: left">Username';
    	$html .= '</th>';
    	$html .= '<th style="text-align: left">Request';
    	$html .= '</th>';
    	$html .= '</tr>';
    	foreach( $reqs as $req ){
    		$user_info = get_userdata( $req['user_id'] );
    		$html .= '<tr>';
    			$html .= '<td>';
    				$html .= $user_info->display_name . ' (' . $user_info->user_login . ')';
    			$html .= '</td>';
    			$html .= '<td>';
    				$html .= $req['sp_req'];
    			$html .= '</td>';
    		$html .= '</tr>';
    	}
    	$html .= '</table>';
    
    	echo $html;
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    This code will show a textarea in the single event page. When user will write something, the data will be saved and you can see the data in the edit event page.

    Please give it a go and let me know if anything is missed.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.