Skip Navigation

[Waiting for user feedback] Creating or removing a relationship with one click

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
- 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 3 replies, has 1 voice.

Last updated by Minesh 6 days, 18 hours ago.

Assisted by: Minesh.

Author
Posts
#2818941

Tell us what you are trying to do?

I have a many-to-many relationship defined between User Profiles and Chapters. I would like to create a link (a single-button form) that will allow users who have authored a User Profile to create a relationship with the Chapter they are currently viewing.
The end result would be just a single button "Join Chapter" or "Leave Chapter".

But the relationship form will not automatically choose the current user's User Profile post, or the current Chapter post that is being viewed. It only displays the option to search for the profile or chapter from a drop-down list.
Is it possible to simplify this form, auto-populate the post IDs, and hide all options except for the button?

Is there any documentation that you are following?

https://toolset.com/course-lesson/front-end-relationship-forms-for-connecting-posts/#deleting-existing-connections-between-posts

What is the link to your site?

hidden link

#2819040

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Yes - there is a way to auto-populate the parnt and child with Toolset relationship form.

For example, you can display the relationship form shortcode like this:

[cred-relationship-form form='my-relationship-form-slug' parent_item="999" child_item='123']

Where:
- you can replace the 999 and 123 with your original post id or required values to setup parent and child.

Please check the following links that may help you:
- https://toolset.com/forums/topic/create-takeaway-menu-order-form/#post-1975379
- https://toolset.com/forums/topic/default-value-of-field-in-many-to-many-relationship-form/#post-2458877
- https://toolset.com/forums/topic/need-to-have-an-front-end-edit-one-to-many-relationship-form/#post-2365793

#2819076

Thank you for pointing me in the right direction. I ended up resolving the issue with a different approach.

Using the 'expert' mode on the relationship form builder, I replaced the default select form fields with hidden ones, and populated the values of the hidden fields with shortcodes for the current chapter being viewed, and the current user's User Profile.

[cred-relationship-form-container]
<input type="hidden" id="cred_association_user-chapter_parent" name="cred_association_user-chapter_parent" value="[wpv-view name='get-current-users-profile-id' cached='off']">
<input type="hidden" id="cred_association_user-chapter_child" name="cred_association_user-chapter_child" value="[wpv-post-id]">
[cred-form-feedback field='feedback' name='feedback']
[cred-form-submit field='submit' name='submit' class='uk-button' value='Join This Chapter']
[/cred-relationship-form-container]

I still have just one problem. The submit button still says "Submit" on it, and adding value=''Join This Chapter' did not change it.
Is there another way that I can change the text on this button?

#2819160

Minesh
Supporter

Languages: English (English )

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

Can you please share problem URL and admin access details and let me check whats going wrong with your setup.

*** 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 have set the next reply to private which means only you and I have access to it.