Modifying raw $_POST data early in the lifecycle

Question

Is there a plugin specific way of modifying the superglobals in a direct manner prior to them being used? Assuming the following code was in a plugin called aaa, one might imagine that this would run quite early in the request lifecycle. While the code runs, when other plugins use the data it has not been altered.

// file location: wp-content/plugins/aaa/aaa.php

function interfere_with_things(){

    // skip anything not applicable
    if($_SERVER['REQUEST_METHOD'] !== 'POST' || empty($_POST['something'])){return;}

    // change something in the $_POST
    $_POST['something'] = str_replace('cats', 'dogs', $_POST['something']);

}

add_action('init', 'interfere_with_things', 1);

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/modifying-raw-_post-data-early-in-the-lifecycle/">

Modifying raw $_POST data early in the lifecycle</a>
0
jamesgarrett 1 week 0 Answers 35 views 0

Leave an answer