-1

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
    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... – Krzysiek Dróżdż Sep 27 '18 at 7:52
0

Maybe this will work better

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

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.