Forums

Adding javascript to header (2 posts)

  1. ocon
    Member
    Posted 2 years ago #

    For my first plugin, I'm trying to add a line of code into the head of the edit user profile page. I'm not able to get it to work:

    <?php
    /*
    Plugin Name: user profile js
    Plugin URI:
    Description: Add javascript to edit user profile page
    Author:
    Version:
    Author URI:
    */

    function my_header_content(){
    echo "<script>...</script>";}

    add_action("edit_user_profile","my_header_content");

    ?>

    Any help is appreciated

  2. apljdi
    Member
    Posted 2 years ago #

    'edit_user_profile' runs long after the head has been closed. Its not going to insert anything into the head section of the page. You should be looking at wp_enqueue_script, admin_head, and admin_print_scripts.

Topic Closed

This topic has been closed to new replies.

About this Topic