Support

Home Forums Wait List Manager Add-on Wait List and Registration Counts?

Wait List and Registration Counts?

Posted: September 30, 2019 at 5:23 pm

Viewing 4 reply threads


brett-BA-Transform

September 30, 2019 at 5:23 pm

I’ve been working off this thread https://eventespresso.com/topic/show-number-of-attendees-for-an-event/ which references this github item, the second file shows an easy way to get Registration counts .

We’re also running the Waitlist add on and the total of registrations is actually the wait list count + the Registration count from ($event_obj)

the $regcount does not seem to calculate anything that I can match up~ not worried about that (its not pending and doesn’t seem to reflect waitlist + registered)

Wondering if there is a way that I can show the actual Registration Count and separately the Wait List count?

have an example running on a staging site https://bitangels.io/events/bitangels-toronto-launch/


//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_details_before_the_content', 'my_event_registration_count' );
function my_event_registration_count( $post ) {
  $event_obj = $post->EE_Event;
  $html = '';
  if ( $event_obj instanceof EE_Event ){
    $reg_count = EEM_Event::instance()->count_related(
      $event_obj, 
      'Registration',
      array( 
        array(
          'STS_ID' => array(
            'NOT_IN',
            array(
              EEM_Registration::status_id_cancelled
            )
          )
        )
      )
    );
    $html .= '<strong>';
    // $html .= $reg_count;
    // $html .= ' of ';
    $html .= $event_obj->total_available_spaces();
        $html .= ' Registered or on Wait List</strong>';
  }
  echo $html;
}


brett-BA-Transform

September 30, 2019 at 7:24 pm

Update – So I think the $reg_count includes Incomplete registrations also…

so $reg_count with the above code is

Approved Registrations
+ Pending Registrations
+ Incomplete Registrations
+ Waitlist Registrations

So is there a way to refine the filter to remove those others, list them separately or only show Approved Registrations.

Showing the number on the Waitlist would be helpful too!


Tony

  • Support Staff

October 1, 2019 at 4:50 am

Ok, so, the answer to your question is yes, you can refine the search done above and you can also pull just the number of waitlist registrations and display that.

The code above pulls ALL registrations related to the event and this part:

'NOT_IN',
array(
        EEM_Registration::status_id_cancelled
)

Tells the model, not to pull registrations that have a status of cancelled, so you could duplicate that and add additional stati to that field to pull the values for each specific reg type, but…

There’s another way you can go about this that might be a little easier to follow:

You have the EE_Event object at this point:

$event_obj = $post->EE_Event;
$html = '';
if ( $event_obj instanceof EE_Event ){

So, inside the above conditional $event_obj is an EE_Event object.

That means you can do something like:

$approved_count = $event_obj->count_related(
    'Registration',
	array(
		array(
			'REG_deleted' => 0,
			'STS_ID'      => EEM_Registration::status_id_approved,
		),
	)
);

$pending_payment_count = $event_obj->count_related(
    'Registration',
	array(
		array(
			'REG_deleted' => 0,
			'STS_ID'      => EEM_Registration::status_id_pending_payment,
		),
	)
);

$waitlist_count = $event_obj->count_related(
    'Registration',
    array(
		array(
			'REG_deleted' => 0,
			'STS_ID'      => EEM_Registration::status_id_wait_list,
		),
	)
);

$approved_count, $pending_payment_count & $wait_list_count will now each equal their respective values.

The above uses the EE_Event object to pull registrations that related to that object, and you set the STS_ID to be the status of the registrations you want.


brett-BA-Transform

October 1, 2019 at 7:13 am

That helps immensely.

In this same function, I’m trying to find the right place to insert the result.

I initially tried and after content scenario, then a before.

add_action( 'AHEE_event_details_before_the_content', 'my_event_registration_count' );

This resulted in displaying this information wherever we run the loop to display upcoming events. Not desirable. I can create filters to exclude that page by page, but trying to find a list of other places on an event post where I could hook in and display this, preferably within the content but before the description, worst case before the venue. I do not see an option in the standard EE themeing options where I can hook into make something new just for this.

Not finding anything other than hooks related to pricing in the documentation.

Maybe I’m missing it https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/ but this seems to be more of a sales page talking up the EE approach and not so much an actual document showing any list of hook/filter options.

I’ve been to http://developer.eventespresso.com/ and this gives a link to the code on github, but again no actual details that I can find in the links or menu there.

Just trying to get in the right ball park….


Tony

  • Support Staff

October 1, 2019 at 8:16 am

The way I would find a hook to use is using Debug Bar with the Actions and Filters Addon, see:

https://developer.wordpress.org/plugins/developer-tools/debug-bar-and-add-ons/

Then in the admin bar, you click Debug -> Action / Filter hooks and it lists them all.

You’ll find all of our hooks being with FHEE__ (Filter Hook Event Espresso) and AHEE__ (Action Hook Event Espresso) but searching for one to using within just the codebase can be tough without knowing every in and out of the codebase imo.

The above should make that a little easier.

Viewing 4 reply threads

The support post ‘Wait List and Registration Counts?’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso