Skip Navigation

Relationships between custom post type to front-end form

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.

This topic contains 4 replies, has 2 voices.

Last updated by michalB-6 3 months, 1 week ago.

Assigned support staff: Minesh.

Author
Posts
#2402289
Zaznaczenie_021.png

Tell us what you are trying to do?

I'm building a directory site. I created a form for adding ads by front-end users. In this form, users have to choose Producer and Model (both are CPT and required fields). The problem is when the user adds his ad and choice Producer and model the relationship between these posts isn't created and when someone uses filters on the ads page this ad isn't presented. How can I add the relationship form to Post Form on Front-end?

Is there any documentation that you are following?
https://toolset.com/course-lesson/front-end-relationship-forms-for-connecting-posts/

#2402499

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know that you are using the post form created with Toolset Forms to create a new entry from frontend for your post type where you added the post reference fields which allow you to select the parent - right?
or
Are you using the post relationship form?

If you can share problem URL and admin access details that would help to me review your current setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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 have set the next reply to private which means only you and I have access to it.

#2403689

Hi Minesh,
yes I'm using the Post Form (not relationship form) created with Toolset Forms to create a new entry from front-end where I have two Post reference filed. Right now I resolved this by adding this pice of code:

add_action('cred_save_data', static function(int $post_id, array $form_data): void {
    toolset_connect_posts('ad-model', $post_id, $_POST['model']);
    toolset_connect_posts('ad-producer',$post_id, $_POST['producer']);
},15,2);

But I think there is a better way to do this.
Regards

#2404033

Minesh
Supporter

Languages: English (English )

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

Yes, this is the right hook you are using and right function to connect the post.

#2406397

My issue is resolved now. Thank you!