MENU

Mandatory name entry when booking in Events Manager

WordPress plugin Events Manager.

When a guest user makes a reservation with the function of this plug-in, he / she can make a reservation even if the name is not entered.

To improve it, add the code below to your theme’s functions.php.

function zipang_em_validate($result, $EM_Event){
  if (!is_user_logged_in() && $_REQUEST['user_name'] == ''){
    $EM_Event->add_error('Please enter your name.');
    $result = false;
  }
  return $result;
}
add_filter('em_booking_validate','zipang_em_validate', 1, 2);

If you also require a phone number, it will look like the following.

function zipang_em_validate($result, $EM_Event){
  if (!is_user_logged_in() && $_REQUEST['user_name'] == ''){
    $EM_Event->add_error('Please enter your name.');
    $result = false;
  }
  if (!is_user_logged_in() && $_REQUEST['dbem_phone'] == ''){
    $EM_Event->add_error('Please enter your phone number.');
    $result = false;
  }
  return $result;
}
add_filter('em_booking_validate','zipang_em_validate', 1, 2);
Let's share this post !
  • Copied the URL !
  • Copied the URL !

Author of this article

Comments

To comment

TOC