function tml_request_callback( &$theme_my_login ) {
if ( 'register' == $theme_my_login->request_action )
wp_enqueue_script( 'my-script', 'http://mysite.com/my-script.js' );
}
add_action( 'tml_request', 'tml_request_callback' );
I need help with something like this, I want to add my cpalead advertiser code to the registration page.
<script type=’text/javascript’ src=’http://www.cpalead.com/mygateway.php?pub=1111111&gateid=1111111′></script>
I attempted putting the code in the ‘http://mysite.com/my-script.js’ area but that didn’t work.
PS: This is supposed to be in theme-my-login/templates/register-form.php , right?
@nomnomnom: Create a file called theme-my-login-custom.php in your plugins directory. Add it there. Replace http://mysite.com/my-script.js with http://www.cpalead.com/mygateway.php?pub=1111111&gateid=1111111.
It doesn’t do anything, looking at the theme-my-login-custom.php page in the wordpress plguin edtior says it’s ‘inactive’, pic below.
[IMG]http://i51.tinypic.com/t84t9v.png[/IMG]
It is included as the first line of code in theme-my-login.php.
By ‘It doesn’t do anything’ I meant that the script doesn’t get inserted into the registration page.
Just to verify something, the theme-my-login-custom.php page should be in /wp-content/plugins/theme-my-login rather than /wp-content/plugins/?
It belongs in wp-content/plugins.
If it were to be placed in the TML directory, it would be lost upon upgrade, therefore defeating the purpose.
I put it in the wp-content/plugins directory amd it ending up locking the entire site with the script, it also seems to mess up the header.
It’s still not right.
First of all, the second parameter of wp_enqueue_script shold be just the script’s URL.
Also, you must use opening and closing PHP tags in the file, for without them, you are just outputting HTML.
Copy this EXACTLY into theme-my-login-custom.php:
<?php
function tml_request_callback( &$theme_my_login ) {
if ( 'register' == $theme_my_login->request_action )
wp_enqueue_script( 'cpalead', 'http://www.cpalead.com/mygateway.php?pub=34025&gateid=MTQxNDQ1' );
}
add_action( 'tml_request', 'tml_request_callback' );
?>
Thanks, sorry about the trouble.