Script issue impacting snippet installation
-
Hello – we are trying to install a snippet in the header of our site to activate a new platform. We are trying to pass through PHP variables ($uuid) into a JavaScript function located within a tag in the of our page. do you know how to properly pass through these variables?
WP.com: Unknown
Jetpack: Unknown
Correct account: Unknown -
Hi there –
Please share the site URL so we can have a closer look. There are some limits as to which code can be embedded when using our managed hosting from WordPress.com.
Take a look: https://wordpress.com/support/code/
-
Apologies – I thought it had linked it when I created this thread – http://www.inunison.org is the site.
-
To elaborate more this is the code we are working on:
We have one PHP snippet that calls for the metadata:
add_action(‘wp_head’, function () {
if(!is_user_logged_in()) { return; }
$user_id = get_current_user_id();
$uuid = get_user_meta($user_id, ‘uuid’, true);
$user_login = get_user_meta($user_id, ‘user_login’, true);
$user_email = get_user_meta($user_id, ‘user_email’, true);
$first_name = get_user_meta($user_id, ‘first_name’, true);
$last_name = get_user_meta($user_id, ‘last_name’, true);
$role = get_user_meta($user_id, ‘role’, true);
$val = get_user_meta($user_id, ‘user_id’, true);
$name = get_user_meta($user_id, ‘mepr_business_name’, true);
$is_paying = get_user_meta($user_id, ‘mepr_subscription_status’, true);
$monthly_value = get_user_meta($user_id, ‘price’, true);
$plan_level = get_user_meta($user_id, ‘mepr_product_id’, true);
$subscriberid = get_user_meta($user_id, ‘mepr_subscription_number’, true);
$creation_date = get_user_meta($user_id, ‘user_registered’, true);
})
?>Then have a snippet that installs the code itself:
<script>
(function(apiKey){
(function(p,e,n,d,o){var v,w,x,y,z;o=p[d]=p[d]||{};o._q=o._q||[];
v=[‘initialize’,’identify’,’updateOptions’,’pageLoad’,’track’];for(w=0,x=v.length;w<x;++w)(function(m){
o[m]=o[m]||function(){o._q[m===v[0]?’unshift’:’push’]([m].concat([].slice.call(arguments,0)));};})(v[w]);
y=e.createElement(n);y.async=!0;y.src=’https://cdn.pendo.io/agent/static/’+apiKey+’/pendo.js’;
z=e.getElementsByTagName(n)[0];z.parentNode.insertBefore(y,z);})(window,document,’script’,’pendo’);
pendo.initialize({
visitor: {
id: ‘$uuid’,
userlogin: ‘$user_login’,
email: ‘$user_email’,
firstname: ‘$first_name’,
lastname: ‘$last_name’,
},account: {
id: ‘$user_id’,
}
})
})(‘0ed4ea1c-7528-481b-514a-05b59c1f8efd’);
</script>”;
} );Any help for what we are doing wrong would be greatly appreciated.
-
Hi there,
We can’t help directly because we don’t host inunison.org on our WordPress.com managed hosting. As a result, we can’t take a closer look at your site.
Instead your host (GoDaddy) uses the open-source variant of the WordPress platform (sometimes called “WordPress.org”) which functions differently than what we offer here on WordPress.com.
The good news is that help is available here at the open-source WordPress forums: https://wordpress.org/support/forum/how-to-and-troubleshooting/
The folks in that forum are more familiar with these kinds of issues and are in the best position to help. Thanks!
- The topic ‘Script issue impacting snippet installation’ is closed to new replies.