Title: get categorys in function
Last modified: May 7, 2018

---

# get categorys in function

 *  Resolved [gavin1978](https://wordpress.org/support/users/gavin1978/)
 * (@gavin1978)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/get-categorys-in-function/)
 * 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](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/get-categorys-in-function/#post-10261123)
 * 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.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/get-categorys-in-function/#post-10261123)
 * Status: resolved