Viewing 14 replies - 1 through 14 (of 14 total)
  • Can you explain in a bit more detail what’s happening? I’m not sure I follow 100%. Thanks.

    Thread Starter elliotlewis

    (@elliotlewis)

    This is happening in a few places.

    I have a custom usermeta field called location.
    I have page that outputs all users. On this page I have a form with a select dropdown that lists some locations (it doesn’t matter how this list is generated), but the select name=’location’. This form submits via ‘get’.

    There are other selects to choose from all matching custom usermeta as well. These selects submit OK and I can access the values to display a filtered view.

    BUT with a select with a value of ‘location’, on submit, WP goes to an events page (‘events’ is the slug EM uses to display an event page).

    Is EM looking out for the word ‘location’ from any form submit and then acting on it?

    It sounds more like the issue with the form being submitted using GET. My guess is that it’s getting confused with an existing permalink.

    Can you post a link?

    Thread Starter elliotlewis

    (@elliotlewis)

    This is site isn’t live yet. Why would it be a problem with the form submitting using GET? It’s most likely to be EM getting confused with it’s permalinks as event pages are showing.

    I’ve written the form code (this isn’t a plugin). The form is submitted to the same page:
    https://example.com/directory/

    Via GET so:
    https://example.com/directory/?location=uk

    I’m then picking up the vars from the URL to manipulate the view. Except with that GET variable WP redirects to an event.

    I think the problem with using a GET submission with a variable called location is that it’s getting confused with the custom post type location which is part of Events Manager.

    When WordPress is dealing with what it thinks is a 404 it tries to find the “correct” page. I’m pretty sure that’s what’s happening here.

    If you don’t need Events Manager locations, you could try deactivating them under Events > Settings > General > General Options.

    Even better, use a different variable name.

    Thread Starter elliotlewis

    (@elliotlewis)

    Ah, I see.

    I’m using pretty permalinks, so I hadn’t considered WP would be trying to evaluate query variables. WP routes is a constant pain. I don’t understand how it can be a 404 because there is a template that works fine without query variables in the URL, ie WP loads the right page. What I mean is, without pretty links it would be:

    https://example.com/?page_id=43&location=uk

    Why is WP getting confused with that? I’ve tried it and you’re right it does 404.

    Unfortunately I am using the built in locations, so I can’t disable it. I already have the ‘solution’ of, ‘use a different GET variable name’. I’m using ‘locations’.

    It would be good to understand how I can configure WP to understand the URL though and not load EMs ‘location’ template. (I’m not using EM location view, just an event list > click > view event.)

    Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry, could it be that it’s a conflict with your custom form?

    Thread Starter elliotlewis

    (@elliotlewis)

    @angelo What would be the conflict?

    The site went live yesterday, so it might help for you to have a look?
    https://www.theengineroom.org.uk/directory/

    This possibly isn’t directly an EM issue but a WP routing one. I’m assuming EM is setting some rules for directing URLs though, and also one of those routes is to handle ‘location’?

    I’m experiencing the same thing.

    I just discovered that the EM plugin is causing issues with my custom signup form, which is a POST submit with a “location” variable name. If I rename this form variable (name attribute) to “location2” (for example), then it submits fine – otherwise my form submits to a 404. I know this behaviour is consistent with WordPress’s own reserved variable names (see https://wordpress.stackexchange.com/a/77339) but I’ve never experienced issues with a plugin before.

    Thread Starter elliotlewis

    (@elliotlewis)

    OK, I’ve re-read this thread a couple of times, and it’s clear how WP is getting confused, as EM creates it’s own CPT called ‘location’ for it’s Locations.

    So WP should load an archive template for /location/ but it 404’ing, so EM is doing something with WP rewrites.

    It’s a bit of a ‘sledge-hammer’ CPT name using ‘location’, wouldn’t ’em-location’ be better? I’m sure others will find this a problem (like @ Damien).

    I think not, because location seems the logical slug to use for the location permalink structure.

    Thread Starter elliotlewis

    (@elliotlewis)

    Makes sense.

    But any help on why it’s 404’ing at not showing an archive template? And how to get around the route issue.

    You’ve not answered if EM does anything with rewrite rules for ‘location’.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can change or override that by adding this to your wp-config.php

    define('EM_POST_TYPE_LOCATION','em-location')
    Thread Starter elliotlewis

    (@elliotlewis)

    Thanks @angelo, but that won’t work for me as I am using EMs locations to display a location on the event. I’m just not using a location archive page to list locations.

    As soon as I override the PT name WP errors.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘EM hijacking form submit GET variable 'location'’ is closed to new replies.