I have a website which shows user profiles and their relevant userID is available on the page where my form is (but hidden through CSS).

(The userID is for the profile being viewed and not the user logged in).

I have a hidden field called "profileUserID", which needs to capture the userID

I want my RSForm to be able to capture that userID and submit it along with the rest of the data.

HTML for the hidden userID is:

<span itemprop="userID" id="userID"><?php echo $userid; ?></span>

In basic terms, I need to get whatever the value for "userID" is and submit this in the form via the profileUserID hidden field.

1 Answer 1


Have you looked at the data available in RS Form in the Forms in the replaceable tag {global:userid} rather than trying to grab the value from some other value displayed on the page. There is a lot of data readily available to the form directly using {}, assuming the UserID you want is the person logged in and filling in the form. enter image description here

In this example I am grabbing the logged in user id and assigning it to the hidden field when the form is displayed. You could also do the same as the form is processed.

$_POST['form']['profileUserID'] = '{global:userid}';

If that is not a viable option for you, perhaps you are not wanting the logged in user but a userid entered elsewhere on the page outside of the form, then you will probably need to add some JavaScript to the Form Properties->Javascript box along the lines of

<script type="text/javascript">
    function book() {
        document.getElementById("profileUserID").value = document.getElementById("userID").innerHTML;

Then on the Submit button Additional Attributes add:


This will run when the page loads and gets the value of UserID field somewhere else on the page and saves the value into the Field created in your form. The userID is the value of HTML id="userID" of the field you want to get and and profileUserID is the id="profileUserID" of the field that you want to set.

  • Thanks, although I'm slightly confused by your example Oct 10, 2022 at 12:59
  • Which bit is confusing, using the {user} tag or the solution to use javascript?
    – Irata
    Oct 10, 2022 at 21:26
  • I have added more detail in the two examples of how you might achieve getting the userid into the hidden field of your form.
    – Irata
    Oct 10, 2022 at 22:41
  • Thanks, I'm testing your JavaScript code, but that doesn't appear to be working. document.getElementById("userID").value; is returning "undefined" Oct 11, 2022 at 9:31
  • 1
    I see you modified my answer to make the javascript a function and added the innerHtml and added an onclick to trigger it. Instead of that you could keep the script not as a function, corrected the innerHtml but then moved it all into the next text area down on the Form Properties and it would be executed at the time the form is processed, thus removing the need for the onclick=.
    – Irata
    Oct 11, 2022 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.