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);
0
wp-query
3 years
2020-03-27T00:53:02-05:00
2020-03-27T00:53:02-05:00 0 Answers
90 views
0
Leave an answer