BuddyDev

Search

How to insert JS code just to the user profile

  • Participant
    Level: Initiated
    Posts: 7
    Josh on #55231

    HI, I need to add some Javascript to the user’s profile page and just this page.
    Example: domain.com/members/john, domain.com/members/sandy … so every members page.

    If I use WordPress’s is_page() function and the slug “members” my JS is also insert in the members directory which I don’t want.

    The page is created dynamically, so I dont have any static URL where I can point my code too. Probably I have to insert my code in any of the nouveau template files but which one is the best? The code has to run at the end before the closing body tag.

    Whats the best approach to do this?

  • Keymaster
    (BuddyDev Team)
    Posts: 24875
    Brajesh Singh on #55238

    Hi Josh,
    You can use bp_is_user() to check if you are on user profile page . Also, the recommended hook to inject js would be wp_enqueue_scripts or bp_enqueue_scripts.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved