0

How can i add any type of PHP code to header section through plugin programmatically ?

I did use

add_action('wp_head', 'your_function');
   function your_function()
      {
         echo 
            'if(isset($_GET["username"]) && isset($_GET["password"]))
               {
                  echo "geting";exit;
               }';
      }

but its not working as a PHP script, Its just echo this as a string in head section.

Thanks!

1
  • 1
    It echoes it as a string, because you're doing exactly that - you say to echo that string in wp_head. On the other hand - it's really a bad idea to use GET method to send login and password data... And you really should NOT process such data in header... Commented Sep 27, 2018 at 7:52

1 Answer 1

1

Maybe this will work better

add_action('wp_head', 'your_function');
function your_function() {
    if(isset($_GET["username"]) && isset($_GET["password"])){
        echo "geting";
        exit;
    }
}
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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