Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hello team,
I am having challenge with the current first project with couchcms.

I am told to use "get_custom_field" to retrieve and store page details. However, I have used it to retrieve extended user's basic detail to be used in form processing. The challenge is it retrieves same record for any extended user that logs in evn though they all have different values to these fields.

Sample code below:
Code: Select all
<input type="text" id="bio_health" value="<cms:get_custom_field var='bio_health' masterpage='users/index.php' page_id='k_user_id' />">
<input type="text" id="bio_dependant" value="<cms:get_custom_field var='bio_dependant' masterpage='users/index.php' page_id='k_user_id' />">
<input type="text" id="bio_next_of_kin" value="<cms:get_custom_field var='bio_next_of_kin' masterpage='users/index.php' page_id='k_user_id' />">


Any assistance from the house, please.
Hi,

In your code, the value being set for the 'page_id' parameter is enclosed in single-quotes -
Code: Select all
<cms:get_custom_field var='bio_health' masterpage='users/index.php' page_id='k_user_id' />

Quotes would make Couch consider the value to be a literal string and hence try to find a (non-existent) page with a literal id 'k_user_id'.

'k_user_id' is actually a variable so you need to remove the quotes e.g. as follows -
Code: Select all
<cms:get_custom_field var='bio_health' masterpage='users/index.php' page_id=k_user_id />

If you are not clear on the quotes issue, please see the docs (https://docs.couchcms.com/concepts/sett ... eters.html) for details.

Hope this helps.
Thanks for the reply and insight, however, it keeps populating those field with the same values for every user that logs onto the platform. May be I could express the exact situation. Please read through my specific scenario below:

This is the scenario, I want to retrieve specific fields of a clonable templete from the 'users/index' template. I have already added these fields which are, health_bio, bio_dependant and bio_next_of_kin.

Now, I want to be able to retrieve these specific values for every extended user that logs onto the platform and use it to process another form. For example, in a clear case of a php would be something like, inside a form:

<input type="hidden" name="health_bio" id="health_bio" value="<?php echo $health_bio; ?>">
<input type="hidden" name="health_bio" id="health_bio" value="<?php echo $bio_dependant; ?>">
<input type="hidden" name="health_bio" id="health_bio" value="<?php echo $bio_next_of_kin; ?>">

Please is there something I am not doing right here?
3 posts Page 1 of 1