0

i'm developing a plugin wich uses GET parametters to decide what to render to the user(example: login, logout, change password etc..), the thing is this works in the standards wordpress themes but when i changed to my clients theme(Sereno) every time i call the url with the parametter it render a POST page... example

if a call http://localhost/myclient/?page_id=822&action=passresset in the standard wp theme it will show what i want but if a change to sereno shows a post page, its weird to my that does not show an 404 error, like this recognizes the URL like a valid one

I'm trying to fix this but i have no idea where to start, i guess the problem should be in the way the template decides what kind of loop it will use but i don't know where the **** its that script..

Pleace help!!

--------------UPDATE---------------

first than all, fuxia thanks a lot for taking time on helping me...

i'm using a widget to handle a type of users (not the same users of WP) which will have access to login, logout, change password, resset password and send requests via a form so my widget class is as follows

class SucursalWidget extends baseWidget {

public function __construct() {
    $widgetOptions = [
        'classname' => 'SucursalWidget',
        'description' => 'Panel de búsqueda para las sucursales',
    ];

    parent::__construct('sucursalwidget', "Widget para las sucursales", $widgetOptions);
}

public function login() {
  //process user login
}

public function logout() {
    session_destroy();
    echo "<h2>Su sesion ha sido terminada</h2>";
    $model = new LoginForm();
    $this->renderPartial('loginform', ['model' => $model]);
}

public function solicitud() {
  //Gets a form an save it on db
}

/**
 * Cambiar contraseña para usuario ya logeado
 */
public function passChange() {

}

/**
 * Recuperar contraseña perdida vía email
 */
public function passResset() {
   //PROCEESS pass resset
}

public function widget($args, $instance) {
    $action = isset($_GET['action']) ? $_GET['action'] : 'login';

    switch ($action) {
        case 'login': {
                $this->login();
            }
            break;
        case 'logout': {
                $this->logout();
            }
            break;
        case 'solicite': {
                $this->solicitud();
            }
            break;
        case 'passchange': {
                $this->passChange();
            }
            break;
        case 'passresset': {
                $this->passResset();
            }
            break;

        default: {
                echo "Página no encontrada";
            }
            break;
    }
}

}

as you can see in the function widget the switch uses the $_GET['action'] to know what to do with depending on the user's actions, this method works just fine when i use a regular WP theme like Twenty Fifteen. I guess the theme (named Sereno) its changing the URLs pattern because when i put any extra get parametter it shows a POST page i would expect an 404 error if something goes wrong, but for some reason is showing the last POST and i have no idea what to search for in the theme code..

1

WordPress is removing all unknown (not registered) $_GET parameters while processing the request (same is true for $_POST).

You can either register the custom variable, or just go the canonical PHP way by using filter_input(). This will access the original, unchanged GET parameters.

If you are using filter_input(), you have to hook into pre_get_posts to change the fetched resource.

You can also filter query_vars and register your custom variable here. This will make sure it is preserved.

add_filter( 'query_vars', function ( $vars ) {
    $vars[] = 'sereno';
    return $vars;
});

Then you can access it per get_query_var( 'sereno' ) now. You still have to change the request somehow if you want to show some custom content.

  • already tried that...the thing is my plugin is not working only with one specific template, i'll love to know where the templates decide what view file to use( i mean archive.php, single.php etc..) so i can see where the template is failling.. – Isan Rodriguez Trimiño Apr 24 '18 at 19:42
  • 1
    @IsanRodriguezTrimiño And here is the basic problem with your question: You left out the crucial part with your own code. :) Please update your question. – fuxia Apr 24 '18 at 20:08
  • first than all, fuxia thanks a lot for taking time on helping me... – Isan Rodriguez Trimiño Apr 25 '18 at 12:55
0

I had found the problem, the thing is this template has taxonomy customizations, i commented

require_once('library/core/twomediax-wp-customizations.php'); // twomediax core custom types and taxonomies

this line is in the function.php, and without this customizations it works, now is giving me othe issues with template widget but i have a path to follow... now i have to struggle with taxonomies

fuxia thanks again for helping me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.