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
  • Can i add wordpress login code here like wp_signon ? Commented Sep 27, 2018 at 6:18
  • You can add any code inside wp_head action, but beware that it will execute on every request. Read more in codex: codex.wordpress.org/Plugin_API/Action_Reference/wp_head Commented Sep 27, 2018 at 7:46

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.