Files
pkrstarsbot/client_webapp/code-snippets/loggedInAs.php
2021-02-16 23:07:41 +01:00

30 lines
666 B
PHP

<?php
add_action( 'wp_enqueue_scripts', 'my_getUserInfo' );
function my_getUserInfo() {
if (!is_user_logged_in()) {
return;
}
if(page_id() === 2) {
global $current_user;
wp_get_current_user();
js_manipulate($current_user);
}
}
function js_manipulate($current_user) {
?>
<script>
// START JAVASCRIPT
document.addEventListener("DOMContentLoaded", function(event) {
const email = "<?php echo $current_user->user_email ?>";
jQuery('#textLoggedInAs .fl-rich-text p').ready(function() {
jQuery("#textEmail .fl-rich-text")[0].textContent = email;
});
});
// END JAVASCRIPT
</script>
<?php
}