Support

Home Forums Event Espresso Premium EE People Add-On Custom Template Page

EE People Add-On Custom Template Page

Posted: February 17, 2017 at 3:05 am


George

February 17, 2017 at 3:05 am

Hello,

I’m trying to create a custom template page for displaying event_people post type.

I have successfully created a template page, my only challenge now is to create an instance variable of the person post which contains all the event_people post details assigned to the user including the categories and person types that user belongs to.

For example $event_person = event_esspresso_instance_of_person ($person_ID);

Also, how can i get the country, state of an event_people post type using the state & country ISO code?

Thanks alot for your help


Tony

  • Support Staff

February 17, 2017 at 4:38 am

Where are you outputting the details? You may already have access to the info depending on what it is your doing.

For example $event_person = event_esspresso_instance_of_person ($person_ID);

Where would $person_id be coming from?

You can pull an instance of a ‘EE_Person’ using:

$person = EEM_Person::instance()->get_one_by_ID( $person_id )

Also, how can i get the country, state of an event_people post type using the state & country ISO code?

I’m not sure I follow what your doing here, where are you pulling the personal state and country name from? If you have an EE_Person object you can use the method available on that object to output the details you need.

For Example if you used the above code $person will be an EE_Person object, so you can do this:

echo $person->state_name() . ' ' . $person->country_name();

If you don’t have it already, I recommend installing Kint on your dev site: https://en-gb.wordpress.org/plugins/kint-debugger/

You can then do d($person); to output all of the information on $person nicely formatted which will allow you to see all of the available methods you can use.


George

February 18, 2017 at 7:00 pm

Thanks alot Tony, your reply was super helpful.

The only challenge i have now is, how can I retrieve ALL “Person Category” and “Person Type” for a particular person?

For example, maybe something like:

$person_types = $person.EE_get_person_types($person_or_$person_id);
$person_categories = $person.EE_get_person_categories($person_or_$person_id);

Thanks.
George.


George

February 18, 2017 at 7:04 pm

And also how can i retrieve all events (upcoming) a person is assigned, and also the roles they’ve been assigned to in each event?


Josh

  • Support Staff

February 20, 2017 at 10:13 am

Hi George,

You can use the get_the_terms() function to list the custom taxonomy terms (role for each event) for the people post type:

https://developer.wordpress.org/reference/functions/get_the_terms/

Then you can re-use the loop from the People add-on’s /public/templates/content-espresso_people-details.php template.

The support post ‘EE People Add-On Custom Template Page’ 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