Controlling event status

This topic contains 5 replies, has 2 voices, and was last updated by  Stephen Harris 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36631

    Is there a way to allow logged in users to have their submissions published automatically, but have non-logged in users’ submissions require admin approval?

    George Carvill
    #36639

    Hi George,

    You can set the status of events created through the front-end forms, but this applies to all users.

    So if you can’t allow logged-in users to use the “normal” admin-side event edit page, then you can use the following snippet to set the status:

    add_filter('eventorganiser_fes_submit_event', function($event, $form) {
         if (is_user_logged_in()){
             $event['post_status'] = 'publish';
         }
         return $event;
    }, 10, 2);
    
    Stephen Harris
    #36660

    Thanks. But I have no idea where to put this code.

    George Carvill
    #36666

    It’s best suited in a utility plug-in, but will work in a (child) theme’s functions.php, see https://wp-event-organiser.com/blog/tutorial/where-should-i-put-code-from-the-tutorials/ for more details.

    Stephen Harris
    #36687

    OK. I put in the code and it works as initially expected. I did find one surprising thing:

    If the user is NOT logged in, they get the “Your Event Has Been Submitted” message as expected.

    But if the person IS logged in, the event is published, but the user does NOT get the confirmation message.

    Maybe this is what was intended because the event is immediately visible?

    As a workaround, I added text to the anti-spam section telling users what to expect.

    George Carvill
    #36713

    Hi George,

    I can’t replicate the “Your Event Has Been Submitted” message.

    Stephen Harris
Viewing 6 posts - 1 through 6 (of 6 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.