How to pull the current user’s email and insert into a script placeholder?

You didn’t provide any information on how you’re getting the script on the page to begin with. Assuming that this is something you have hardcoded into your template, here is a way you could approach it.

First, you need to check if the user is logged in, because if they are not, there’s no point in outputting anything since you wouldn’t have any data.

Next, use wp_get_current_user() to get the current user’s info in a standard WP user object. The user’s email address will be in that object as $user->user_email.

Here’s what that looks like in practice:

<?php
// Is the user logged in?
if ( is_user_logged_in() ) {
     // Get the current user.
     $user = wp_get_current_user();
     // Output your script.
     ?><script>
          rewardful('convert', { email: '<?php echo $user->user_email; ?>' })
     </script><?php
} ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)