Skip Navigation

[Resolved] How to have conditional form based on the post ownership

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 11 replies, has 2 voices.

Last updated by omidrezaO 7 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#493084

Hi,
I Have 4 CPTs with the following relationships:
Travel Agency(Parent) (One)< ----------->(Many)Tour(child)
Tour(Many)<----------------Tour-Hotel(CPT)--------------------->(Many)Hotel

I want to allow Travel agencies make their own CPTs(done via Cred), and then make their tours,
But each time they want to make a new tour , the below section allow them to choose the parent:
[cred_field field='_wpcf_belongs_travel-agencies_id' value=""]

My question is, how can I limit this list to only those (travel agencies list) which the current user owns? in other word, each user usually owns only one Travel agency and this field must show only that travel agency to the user.

Thanks a lot

#493112

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand you would like to display only parents that belong to the current logged user with your parent dropdown box - correct?

If above is correct:
I've shared the similar solution which needs some custom programming with clear step information.
=> https://toolset.com/forums/topic/populate-cred-form-with-2-parents/#post-404588

I request you to follow above step information and try to resolve your issue.

#493139

Thanks Minesh for your quick reply, I followed your instruction till step 5, could you please explain more about:
5. in Views > Compatibility > 3rd party ShortCodes register:

where should I do this part please

#493166

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - that menu has changed.

You need to register shortcode at:
=> Toolset => Settings => Front-end Content Tab => Third-party shortcode arguments

#493169

i registered get-parents under 3rd party list and put the form under the post , but no success, do you anyone who can help me on this hourly basis?

#493186

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Sorry - No hourly basis 🙂 but I can help you.

Can I have problem URL and test case with your expected output.

*** 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.

#493212

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Sorry supplied wp-admin access details are not working. Could you please test once and resend back.

I have set the next reply to private which means only you and I have access to it.

#493236

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now.

#493256

Great , Thanks,
first of all please tell me how did you fix the issue, it will help me for future needs

secondly, at the moment the user has 3 options on this field:
1- not set
2- no parents
3- correct parent

how can I fix this choice to 3rd option only?

#493294

َAlso there is some auto CPT appears after each Tour registration, it's named:
CRED Auto Draft b6e5410c61ffe18cd29d018688ce7b39
how can I avoid such auto CPT generation?

#493346

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you did not change the post_type in following code:

function get_parents($atts) {
    global $current_user;
    get_currentuserinfo();
    $author_query = array('post_type' => 'travel-agencies', 'posts_per_page' => '-1','author' => $current_user->ID,);   /// change "page" with your parent post_type slug
    $author_posts = new WP_Query($author_query);
    $parent_ids = "";
    while($author_posts->have_posts()) : $author_posts->the_post();
        $parent_ids .= get_the_ID() .",";
    endwhile;
     
    return $parent_ids;
}
add_shortcode('get-parents', 'get_parents');

Also - you forget to add following line of code to your CRED form.

<input type="hidden" id="parents_id" value="[get-parents]" /> 

As your original issue is resolved. For your all other queries, please kindly open a new ticket, this will help other users searching on the forum.

#493363

Many thanks

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