How to apply a function only for the current user by pressing the button?

How to apply a function only for the current user by pressing the button?
I'm new to worpress environment and once again, I have a question
How to apply a function(hook add_filter) to the user who pressed the button? but
only to him and all the other function are not need

I was able to build code like this
<?php
is the add_shortcode ('T1','A2');
 function A2(){ 
$X0 = plugin_dir_url( __FILE__ ); 
$X1= '<form method="POST" action="';
$X2= '4.php" enctype="multipart/form-data" ">
 <p>Select a filter</p>
 <p><input type="radio" name="p1" id="n1" value="1"> Filter 1</p>
 <p><input type="radio" name="p1" id="n2" value="2"> Filter 2</p>
 <p><input type="radio" name="p1" id="n3" value="3"> Filter 3</p>
 <p><input type="submit" value="Update"></p>';
$X3 = $X1.$X0.$X2;
 return $X3 ;
}
?>

4.php
<?php
$I1 = $_POST ['p1'];
if ($I1 == '1')
{
echo 'Mir' ;
} 
else if ($I1 == '2')
{
function V2($the_content){
return "lol";
}
add_filter('the_content', 'V2');
} 
else if ($I1 == '3')
{
add_filter('pre_get_posts','exc_post'); 
exc_post function($query) {
if ($query->is_category || ($query->is_home || ($query->is_feed) || ($query->is_tag))) 
{
$query->set('tax_query', array( 
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => array("blue","red"), 
'operator' => 'NOT IN'
)
));
}
return $query;
}
} 
else 
{
}
?>

but unfortunately after clicking the filter button 2,3

gives me the following error

Fatal error: Uncaught Error: Call to undefined function add_filter() in C:\xampp\htdocs\wor\wp-content\plugins\GOG6\4.php:24 Stack trace: #0 {main} thrown in C:\xampp\htdocs\wor\wp-content\plugins\GOG6\4.php on line 24

anyone knows how to solve this problem
please tell me
March 12th 20 at 08:08
0 answer

Find more questions by tags WordPress