Skip to main content
Pre-populating username and email
Anastasiia Serebrianska avatar
Written by Anastasiia Serebrianska
Updated over a week ago

When a user provides her or his feedback by submitting an idea, bug report or comment she/he needs to provide name and e-mail.

If your website supports authorization and the current user is logged in - most likely you would know the user name and e-mail and there is no good reason to force the user to enter this information again. UserReport snippet provides the possibility to pass default name and e-mail and user may choose to change it.

window._urq = window._urq || [];
_urq.push(['setFeedbackForumUserName', 'Alejandro']);
_urq.push(['setFeedbackForumUserEmail', '[email protected]']);

Most likely, user name and e-mail is known on the server when rendering page, so here is an example on PHP how it can de dynamically:

<?php 
// Assuming that getCurrentUser() function return assoc array with name and email keys, like
// array('name' => 'Alejandro', 'email' => '[email protected]')

$user = getCurrentUser();
?>
<script>
if ($user)
// Serialize object to protect again XSS injection
var user = <?php echo json_encode($user); ?>
window._urq = window._urq || [];
_urq.push(['setFeedbackForumUserName', user.name]);
_urq.push(['setFeedbackForumUserEmail', user.password]);
)
</script>

If you add Feedback widget into IFrame or generating URL to it dynamically you can also send default name and e-mail as well, by following adding userName and userEmail parameters in hash-part of URL. Here is an example of such link:

Did this answer your question?