Title: Pass a php variable to a plugin
Last modified: August 21, 2016

---

# Pass a php variable to a plugin

 *  [elsnare](https://wordpress.org/support/users/elsnare/)
 * (@elsnare)
 * [13 years ago](https://wordpress.org/support/topic/pass-a-php-variable-to-a-plugin/)
 * I have a website with a plugin that generates PDF files out of post content and
   qTranslate installed for handling multi-language content.
 * **The problem:**
    The PDF plugin unfortunately does not recognize the languages
   correctly resulting in wrong content being put into the final file. I fixed the
   issue but the solution requires to pass a current language code to the plugin
   so it gets the right post content lang version.
 * **The code:**
 *     ```
       if(qtrans_getLanguage()=='en') {
             $code= "en";
           } elseif(qtrans_getLanguage()=='de') {
             $code= "de";
           }
       ```
   
 * The code above is used to pass the variable with the current lang code. It works
   in theme files, does not pasted directly to the plugin or functions.php. (I’m
   probably doing sth wrong here but I’m def. not a pro at php coding 🙂
 * **Other info:**
    -  Adding the variable $code =’en’; manually in functions.php and calling it
      in the plugin via **global $code;** gets the job done nicely.
 * Thanks in advance

Viewing 1 replies (of 1 total)

 *  [David Choi](https://wordpress.org/support/users/wpthemes777/)
 * (@wpthemes777)
 * [13 years ago](https://wordpress.org/support/topic/pass-a-php-variable-to-a-plugin/#post-3780692)
 * You can study this code using setlocale()
 * [http://pastebin.com/8VTjR7fx](http://pastebin.com/8VTjR7fx)

Viewing 1 replies (of 1 total)

The topic ‘Pass a php variable to a plugin’ is closed to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [David Choi](https://wordpress.org/support/users/wpthemes777/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/pass-a-php-variable-to-a-plugin/#post-3780692)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
