Show events from current logged-in user
Last Updated: November 2, 2021
The ActionUser addon makes it possible to assign users to events and you can learn more from this tutorial: How to assign users to events.
If you also use the ActionUser front-end submission form, you can set it via settings so the registered user that creates the event will be assigned to the event he created.
ActionUser > Event Submission Form > Assign logged-in user to event after successful event submission.
Once you have done this you can use the below code to create a calendar that will only show the events that are assigned to current logged-in user (of your site).
<?php if(function_exists('add_eventon')){ $user_ID = get_current_user_id(); if(!empty($user_ID)){ echo do_shortcode("[add_eventon users='".$user_ID."']"); } } ?>
You can place this PHP code inside a PHP file in your theme template where ever you need this calendar to show.
Method #2:
Since ActionUser v1.8 you can do this with the below shortcode
[add_eventon currentuser="yes" ]
That will show events only from the current logged-in user. However, this shortcode will show all the events if the user is not logged in.
Did this article help you?