Last active
August 29, 2015 14:16
-
-
Save bappi-d-great/7a1c9fe08d371612d9b9 to your computer and use it in GitHub Desktop.
Take extra data when someone click on "I am attending"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'eab-rsvps-button-no', 'get_req_form', 10 ); | |
function get_req_form( $content ){ | |
global $post; | |
if( is_user_logged_in() ) | |
$form = '<div class="sp_req_wrap"><textarea name="sp_req" placeholder="Special Request"></textarea></div>'; | |
else | |
$form = ''; | |
$content = $form . $content; | |
if( is_super_admin() ) { | |
$req = '<h3>Special Requests</h3>'; | |
ob_start(); | |
sp_req_callback( $post ); | |
$req .= ob_get_clean(); | |
} | |
else{ | |
$req = ''; | |
} | |
return $req . $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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment