Skip Navigation

[Resolved] Split: Limit the parent post selector for a form to publish repeatable field groups to own posts

This thread is resolved. Here is a description of the problem and solution.

Problem:
A front-end form is used to publish repeatable field groups and includes a select dropdown to specify which post the group belongs to. Client wants this dropdown to only show the user's own posts, not all posts.

Solution:
Add the attribute author="$current" to the cred_field shortcode for the parent post selector field.

This support ticket is created 5 years, 7 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by anandG-3 5 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#1092909

I have a post type "Expert Profiles"

I have repeater fields in it. So I made two separate forms for those pieces of content.
Repeatable Problem Solution Fields Form (ID: 994)
Work History Repeatable Fields form for Expert Profiles (ID: 996)

Here is an example link
hidden link
It works fine. I only want to make sure that other users cannot update someone else's content.

At the moment , by filling the form at
hidden link
You can update anyone's profile content through the repeater fields form.

I see that I cannot use access to sort this.

#1092955

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I looked at this on your site.

It seems like to add problem solving fields to an expert profile, right now you just have the form added to the page add-problems-you-would-like-to-solve/. The form includes an expert select dropdown, and you can add fields for any expert.

The normal workflow is to link to such a page from the expert to whom the repeatable field groups should be added, in the same way you would add child posts for a parent, as described here: https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

In that case you would normally hide the parent selector with CSS, but that wouldn't stop someone determined to mess with your site to use the browser inspector to change the selected expert.

However, you can add an author attribute to the cred_field for the parent selector, which can take an actual user id, or you can use $current for the currently logged in user.

Right now you have this for your parent selector field in your form:

[cred_field field='@pobz-solving-exp.parent' select_text='--- not set ---' class='form-control' output='bootstrap']

To only show experts in that dropdown that were published by the current user you could add:

[cred_field field='@pobz-solving-exp.parent' select_text='--- not set ---' class='form-control' output='bootstrap' author="$current"]

I think that covers your use case?

#1093256

Thank you very much Nigel. That author="$current"] was very powerful solution. It works very well. It is definitely a dream come true as the site starts working the way we want it to. Thank you..

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.