Title: Script contains PHP and does not work
Last modified: February 8, 2021

---

# Script contains PHP and does not work

 *  Resolved [ARCangelGIRL](https://wordpress.org/support/users/arcangelgirl/)
 * (@arcangelgirl)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/script-contains-php-and-does-not-work/)
 * Hello,
 * I was testing “3rd party cookies” functionality and faced one issue. One of my
   scripts that I had in functions.php file has some dynamic info (current user 
   email address) that I gather using PHP. After getting user email I just echo 
   it inside the JS script.
 *     ```
       <?php $current_user = wp_get_current_user();
         $userEmail = $current_user->user_email; ?>
         <script defer async type="text/javascript">
         var cpaAccount='test';
         var cpaE='<?php echo $userEmail; ?>';
         ............
       </script>
       ```
   
 * When I place that code inside the “3rd party cookies” section it does not work.
   Looks like, that it does not understand the PHP part and works only JS part.
 * Any suggestions or workarounds for this?
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Moove Agency](https://wordpress.org/support/users/mooveagency/)
 * (@mooveagency)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/script-contains-php-and-does-not-work/#post-14039923)
 * Hi [@arcangelgirl](https://wordpress.org/support/users/arcangelgirl/),
 * Thanks for your comments.
 * We have a PHP checker feature implemented in our plugin, you can align your code
   snippet using the consent checker PHP functions, like:
 *     ```
       if ( function_exists( 'gdpr_cookie_is_accepted' ) ) {
         /* supported types: 'strict', 'thirdparty', 'advanced' */
         if ( gdpr_cookie_is_accepted( 'thirdparty' ) ) {
           $current_user = wp_get_current_user();
         $userEmail = $current_user->user_email; ?>
         <script defer async type="text/javascript">
         var cpaAccount='test';
         var cpaE='<?php echo $userEmail; ?>';
         ............
       </script>
         } 
       }
       ```
   
 * You can find all the available hooks and functions in plugin settings -> Help,
   Hooks, Filters & Shortcodes -> Default hooks.
 * Hope this helps.
 *  Thread Starter [ARCangelGIRL](https://wordpress.org/support/users/arcangelgirl/)
 * (@arcangelgirl)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/script-contains-php-and-does-not-work/#post-14042970)
 * Great, thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Script contains PHP and does not work’ is closed to new replies.

 * ![](https://ps.w.org/gdpr-cookie-compliance/assets/icon-256x256.png?rev=2376316)
 * [GDPR Cookie Compliance - Cookie Banner, Cookie Consent, Cookie Notice for CCPA, EU Cookie Law](https://wordpress.org/plugins/gdpr-cookie-compliance/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gdpr-cookie-compliance/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gdpr-cookie-compliance/)
 * [Active Topics](https://wordpress.org/support/plugin/gdpr-cookie-compliance/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gdpr-cookie-compliance/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gdpr-cookie-compliance/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [ARCangelGIRL](https://wordpress.org/support/users/arcangelgirl/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/script-contains-php-and-does-not-work/#post-14042970)
 * Status: resolved