• We were using a shortcode that had a custom attribute (ATT_{facilitators}) in its orderby and it worked fine until a recent update (not sure if it happened with 6.6.3). If we remove the custom attribute from the orderby, the shortcode works as expected. With the custom attribute in the sortby, the shortcode returns “no events found”.

    Here’s an example of the shortcode that works:

    [events_list scope="2024-05-01,2024-05-31" limit="0" orderby="event_start_date,event_name"]#_EVENTLINK[/events_list]

    Here’s an example of the shortcode that returns “no events found”:

    [events_list scope="2024-05-01,2024-05-31" limit="0" orderby="event_start_date,event_name,facilitators"]#_EVENTLINK[/events_list]

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • joneiseman

    (@joneiseman)

    When I look in the documentation it doesn’t indicate that you can order by custom attributes: https://wp-events-plugin.com/documentation/event-search-attributes/#orderby

    So, I’m surprised this ever worked. Maybe it was just ignoring the custom attribute and now it’s not ignoring and instead returning no events for invalid orderby values. It is probably checking now for valid values. I think it was the following change in version 6.5:

    Added sanitization/decoding options for shortcode format content due to security implications.

    Thread Starter Nate Angell

    (@ixmati)

    You may be correct that the custom attribute never affected the sorting, but failed more gracefully @joneiseman. Thank you for bringing that up!

    Until such a capability were added, it might be nice if the documentation made clear that custom attributes are NOT supported in orderby, and/or that the failure when they are was more informative.

    If there’s a way for me to make a suggestion for the documentation directly, I’m happy to do that is anyone can point me to the right mechanism to do so.

    joneiseman

    (@joneiseman)

    I tried installing Events Manager 6.2.1 and added an custom event attribute #_{facilitators} and then created a new event. I then added a page with your shortcode and it returned “no events”. So, I don’t think this ever worked. I agree it would be nice to update the documentation to say that orderby custom attributes is not supported (until if and when it is supported).

    I tried your shortcode (after adding the #_{facilitators} custom event attribute) and I got the following error:

    WordPress database error Unknown column ‘facilitators’ in ‘order clause’ for query

    This is why it says there were no events. I agree that the documentation should be updated to give a list of the supported orderby keys. I think it’s just event_start_time and event_name.

    Thread Starter Nate Angell

    (@ixmati)

    Thanks for looking at this @joneiseman! For us, the big change was not whether the custom attribute was really affecting the order of results, but that it used to fail gracefully and let results through (which did disguise that it was having no effect), but in some update version started to fail harder and not let any results through. I can see how the harder fail is preferable, but it would have been nice to see a hint in the UX (as opposed to debug notices), or at least in the documentation that custom attributes are not supported in orderby. Our content managers spent cycles trying to figure out what was going on in production (where debug is not turned on) and it took some time to narrow it down to this specific change. Again, I’m happy to contribute to documentation if someone can point me to the right path — eg, is there a git repo to make a pull request against?

    Hi Nate,

    I’m not the plugin owner so there’s no way for me to change the documentation.

    I did some more investigation and I found the cause of the problem. In version 6.6.3 of the plugin there was a change to the function build_sql_x_by_helper in the file wp-content/plugins/events-manager/classes/em-object.php and this was causing it to no longer remove invalid orderby keys. Prior to this the “facilitators” key was just getting removed and this was no longer happening due to the erroneous change. The following 2 lines were erroneously added after line 1003 in em-objects.php:

                    }elseif( array_key_exists( $key, $accepted_fields) ){
    $x_by[] = $field;

    Hopefully, the plugin owner will fix this in the next release.

    Thread Starter Nate Angell

    (@ixmati)

    Thanks @joneiseman, great sleuthing! I wasn’t expecting you to facilitate changes to documentation, I was just leaving my offer to help here in this public conversation.

    Whatever the resting place of how custom attributes work in orderby in shortcodes, my hope would just be that better signals are sent to plugin users what is actually happening so they know what’s going on. Adjustments to documentation and perhaps also to the output of shortcodes that include invalid values could both help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.