Tell us what you are trying to do?
I have a Custom Post Type called 'Client'. This post type is setup to mirror a User Role (also called 'client') - it has been setup this way so that I can create a Relationship between Clients and other Post Types in my website (as this is not possible between User Roles and Post Types).
One of the custom fields that I have attached to the 'Client' custom post type (ie NOT the user role, but the post type), is 'Telephone Number' (slug is 'client-phone-number').
When a 'Client' logs into the site, I have a page where they can go to make a request to the website admin to be contacted, I have set this up using a 3rd party Form Plugin (called 'Forminator Pro' - hidden link). The reason I have used this instead of a Toolset form, is that this form is basically just like a standard contact form (I don't need it to create a post or a user), and I have seen it mentioned on other forum posts for Toolset, that you should not use Toolset Forms for basica contact forms.
So, my question is as follows:
When a 'Client' (User Role) is logged into the site, and they go to the page with the Forminator Form on it, I would like this form to pre-populate the Phone Number field with the 'client-phone-number' custom field from the 'Client' post type, how can I do this please?
I have tried generating the short code for this and placing it in the default value field on the form, but this just displays the short code as a text string, so I am guessing that I will need a code snippet to add to my functions.php file.
Are you able to provide me with some example code to try?
If it helps, the 'ID' of the input field I am trying to pre-populate is 'forminator-field-phone-1'
Thank you very much for your help,
Keith
Is there any documentation that you are following?
I tried searching through the forum but I couldn't find anything similar to my issue.
Is there a similar example that we can see?
No
What is the link to your site?
Under development but I can provide full access if required (via a private box), many thanks.
There are two parts to this: how to get the phone number belonging to the logged in user, and how to use that value to prepopulate a Forminator form.
We can't really help with the second part: if you cannot use shortcodes to provide a default value for a form, you'll need to consult with the Forminator documentation or support about what is possible here.
As for the first part, if you have connected the client post type to users with the client role, I assume you have done that by making the user the author of the client post.