• Resolved gavin1978

    (@gavin1978)


    Hi I am really struggling with this, I am trying to restrict booking to three a week in just one category. This code works globally but I can not get it to restrict by category.
    Any help would be greatly appreciated.

    function my_em_mods($result,$EM_Booking)
    {
    	global $wpdb, $current_user, $EM_Notices, $EM_Person, $EM_Location, $EM_Category, $EM_Event, $wp_query, $post, $em_category_id;
    		$EM_Person = new EM_Person( get_current_user_id() );
    		$EM_Bookings = $EM_Person->get_bookings();
    		$bookings_count = count($EM_Bookings->bookings);
    		$EM_Category = new EM_Category($atts['category']);
    		if($EM_Category('micro-pt') && $bookings_count > 2 && $EM_Booking->get_status()!=3)
    		{
                  $EM_Booking-> errors = array_merge($EM_Booking-> errors, array ('You have already booked 3 classes this week'));
                  $result = false ;
           }
    	      return $result;
    
    }
Viewing 1 replies (of 1 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try something like

    
    $EM_Categories = $EM_Bookings->get_event()->get_categories();
    foreach($EM_Categories as $EM_Category){
    
      $category_name = $EM_Category->output("#_CATEGORYNAME");
    
      ...
    
    }
    
    
Viewing 1 replies (of 1 total)

The topic ‘get categorys in function’ is closed to new replies.