Home » Documentation » Professional Translation » Adding Affiliate ID to Themes

Adding Affiliate ID to Themes

Step 1) Add your affiliate ID to the theme

If you already have an account at ICanLocalize, log in (or create a new account).

Then, click on the Affiliate tab.

You’ll see a box with the affiliate information (highlighted in the image above).

This code includes your affiliate ID and key and looks like this:

define('ICL_AFFILIATE_ID', YOUR_AFFILIATE_ID);
define('ICL_AFFILIATE_KEY', 'YOUR_AFFILIATE_KEY');

Insert this in functions.php in the theme.

Your code never changes and you can insert it to as many themes as you like.

Step 2) Validate your affiliate ID

WPML allows you to validate your affiliate data. This will help you ship out themes, knowing for sure that when your clients order translation work you’ll be credited.

To enable validation, you need to add the following PHP code:

define('DEBUG_WPML_AFFILIATE',true);

The best place to add this code is to the wp-config.php file, just before where it says to stop editing. After you’re done with this check, remember to remove that line.

When DEBUG_WPML_AFFILIATE is set, an Affiliates item will appear in WordPress, under the WPML menu.

Affiliate validation form

You cannot edit the values in this form. WPML takes them from the affiliate defines that you entered before. The idea is to simulate what happens when your clients create account in ICanLocalize.

This form will check that both the affiliate ID and key are found in the theme and will validate them with ICanLocalize. If it says the affiliate information is correct (as shown in the image), you’re done.

Otherwise, double check the PHP you’ve inserted and make sure it’s in the right place.

Note: DEBUG_WPML_AFFILIATE is meant for you to check that you’ve inserted the affiliate information correctly. When you’re done building the theme, remove this constant. The Affiliates menu will disappear from WPML.

16 Responses to “Adding Affiliate ID to Themes”

  1. Eduardo says:

    Hi,
    You didn’t specify this, but the DEBUG_WPML_AFFILIATE information should be put into the wp-config.php, right?

  2. Daniela says:

    I don’t have a website.
    Sorry I do not find the “functions.php”, to insert my code. where is it?

  3. The Debug feature doesn’t seam to be working. Can this be a WordPress 3.0 issue?

  4. I figured out that the debug constant has to be defined in wp-config.php and the other 2 affiliate constants can be set in functions.php.

    Now, one one BIG problem remains: the code does not validate!

    The code appears correctly in the form (as it should). Only, when I press the button, I get a message saying it did not validate. It should work, right?

  5. Steven says:

    Added the debug code to wp-config after reading the other comments. (You really should’ve made that clear in the article!) Affiliate menu shows up, when I click I see my numbers and a narrow empty yellow box under the white form that spans the width of the screen. But clicking “Test” has no effect.

    I can see the browser tries to load
    http://my domain]/wp-code/wp-admin/admin.php?page=sitepress-multilingual-cms/menu/languages.php
    but nothing changes on screen.

    Could this be related to this?
    http://forum.wpml.org/topic.php?id=1758

  6. Nina says:

    I don’t have a website.
    Sorry I do not find the “functions.php”, to insert my code. where is it?

  7. Martin says:

    Please update your instruction #2.
    As Steven and Eduardo commented earlier, it is very not clear that we need to paste the ‘DEBUG_WPML_AFFILIATE’ within the “wp-config.php” to have access to the “Affiliates” tab of the WPML menu.

    • amir says:

      You’re right. I added a note about it.

      After you’re done validating, remember to also remove that line from wp-config.php (added a note about that too).

  8. Jeff McNeill says:

    This doesn’t work for me. I did both things (functions.php and wp-config.php). Running 3.0.2 and WPML 2.0.1

  9. maymay says:

    where is functions.php?

  10. Refael says:

    Hi
    I put this code in wp-config.php :
    define(‘DEBUG_WPML_AFFILIATE’,true);

    Before this line as explain in the instructions
    /* That’s all, stop editing! Happy blogging. */

    Then i put my Affiliate ID and Affiliate Key inside function.php
    in my theme

    But the form doesn’t validate

    Please advice what to do

    • Amir says:

      We’ll need to debug this, on your site, to understand what’s happening. Please start a thread in our forum and indicate that you can give login details to our supporters. They will contact you directly to get the login details privately.

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>