Advertisement
eventsmanager

Custom Attendee Form - hides Attendee #1

Mar 10th, 2014
1,332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. /**
  2. * This snippet will hide the first Attendee Form Fields and use the logged-in user info as first attendee or
  3. * the filled-up user name/email
  4. *
  5. * Things to change:
  6. * #attendee_name => your attendee form name field
  7. * #attendee_email => your attendee form email field
  8. * #user_name => your 'Booking Form - General Information' name field
  9. * #user_email => your 'Booking Form - General Information' email field
  10. *
  11. * Note:
  12. * - This is when Multiple Bookings Mode is turned off
  13. * - Make sure that you reverted back to the original EMPro php files or remove your hack codes
  14. *
  15. *
  16. */
  17.  
  18. function my_em_mod_attendee(){
  19. if ( is_user_logged_in() ){
  20.  
  21. global $current_user;
  22. get_currentuserinfo();
  23.  
  24. $email = $current_user->user_email;
  25. $name = $current_user->user_firstname.' '.$current_user->user_lastname;
  26. ?>
  27. <script>
  28. jQuery(document).ready( function($){
  29. var current_forms = $("div.em-attendee-fieldset").find('.em-attendee-fields');
  30. var selected = jQuery('.em-ticket-select :selected').text();
  31.  
  32. for( var i= 0 ; i < selected; i++ ){
  33. if (i > 1){
  34. jQuery('.em-attendee-fieldset').show();
  35. }else{
  36. jQuery('#attendee_name').val('<?php echo $name; ?>');
  37. jQuery('#attendee_email').val('<?php echo $email; ?>');
  38. }
  39. }
  40. });
  41. </script>
  42. <?php
  43. }else{
  44. ?>
  45. <script>
  46. jQuery(document).ready( function($){
  47. jQuery('#user_name').keyup(function() {
  48. jQuery('#attendee_name').val(jQuery(this).val());
  49. });
  50.  
  51. jQuery('#user_email').keyup(function() {
  52. jQuery('#attendee_email').val(jQuery(this).val());
  53. });
  54.  
  55. });
  56. </script>
  57. <?php
  58. }
  59. ?>
  60. <script>
  61. jQuery(document).ready( function($){
  62. var selected = jQuery('.em-ticket-select :selected').text();
  63.  
  64. if (selected == 1){
  65. jQuery('.em-attendee-fields').each(function(i){
  66. if (i == 0){
  67. jQuery(this).hide();
  68. }
  69. });
  70. }
  71.  
  72. jQuery('.em-booking-form select.em-ticket-select').change( function() {
  73. jQuery('.em-attendee-fields').each(function(i){
  74. if (i == 0){
  75. jQuery(this).hide();
  76. }
  77. });
  78. });
  79. });
  80. </script>
  81. <?php
  82. }
  83. add_action('wp_footer', 'my_em_mod_attendee',100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement