This support ticket is created vor 7 Jahren. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
I am trying to:
Use CRED Foms to create event participations of logged in users via a link from the event
I followed your recipy under https://toolset.com/documentation/user-guides/cred-forms-for-child-content/
You are using the CPT: book, reader, review (child of the other two)
I use the CPT: event, person, participation (child of the other two)
The IDs of "persons" are identical to the IDs of the users
I managed to pre-polulate the event with the cred child form link
However, I have no idea how to pre-populate the person parent field with the ID of the currently logged in user
Obviously you did this (preselecting the reader) on your example above, but did not document it.
Hello. Thank you for contacting the Toolset support.
As I understand you just want to prepopulate the parent "_wpcf_belongs_person_id" with current user id and your aim is to not to display this field but save the field automatically having current user id - correct?
If this is true - you should add generic hidden field with same field name:
Generally this works, however, I had a conceptional error in my approach.
I have a CPT "person".
Each "user" is associated to a "person" via a field with the slug "benutzer-id" in the CPT "person". This field holds the ID of the associated "user"
I have to use this approach because a "user" cannot be a parent of a CPT.
So the ID I would have to store under _wpcf_belongs_person_id is:
- the ID of the "person" associated to the currently logged in "user"
- and not the ID of the currently logged in "user"
I suppose I need a function to retrieve the ID of the "person" associated to the currently logged in "user" and put this value into the cred form.
Yes - that is correct, you need to write such shortcode or function to retrieve that associated user_id.
Could you please tell me the benutzer-id is stored as custom user field or where exactly we can find it. If you can share test example where I can see the user_id for person which you want to reference to cred field I can help you to write such shortcode or function.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Thanks for sharing all information. But could you please stop editing as I try to edit CRED form but it says the admin is editing currently and having all rights so I'm not able to make any changes.
Could you please stop editing or logout for now, so I can start checking further.
I've build a custom shortcode that return the post person ID based on the current logged in user which will compare the custom user field in person post = cureent user id.
I've added that code to your theme's functions.php file as that is the recommended way to add any custom code: