Skip Navigation

[Resuelto] Relationship form in CRED form AND show only own posts (author = current user)

This support ticket is created hace 3 años, 5 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

Este tema contiene 8 respuestas, tiene 2 mensajes.

Última actualización por KonstantinS88 hace 3 años, 5 meses.

Asistido por: Waqar.

Autor
Mensajes
#2095929

I would like to have a relationship form that only shows posts where the current user is the author. Not all posts in the system.

Ideally, I would also like to implement it in a regular CRED form.

How can I accomplish this?
Thanks in advance 🙂

#2096345

Hi,

Thank you for contacting us and I'd be happy to assist.

In regular form to create a new post or edit an existing one, you'll see a related post field if the relationship type is one-to-many and the post that is being created/edited can only have one related post.

For example, in the one-to-many post-relationship between Pages and Posts (where 1 Page can have many Posts), you'll see the option to add a relationship field to select a related page in the form to add/edit a Post, but not in the form to add/edit a Page.

For all other cases where a post can have more than one related post, you'll need to use the relationship form for making the connections.

And whether you're using the relationship field in the post form or the relationship form, you'll see the option to show only the posts from the current user as the author, in the field settings.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2099157

I do not quite understand your answer.

With "regular form" you mean the backend Gutenberg editor? I am using the CRED forms in the frontend, nothing in the backend.

"And whether you're using the relationship field in the post form or the relationship form, you'll see the option to show only the posts from the current user as the author, in the field settings."

No, I do not see this option. Neither in the backend form nor in the relationship form settings.

#2099209

I apologize if my message caused confusion.

> With "regular form" you mean the backend Gutenberg editor? I am using the CRED forms in the frontend, nothing in the backend.

- Using Toolset Forms, you can create these 3 types of forms, which are used on the front-end:

a). Post Forms
b). User Forms
c). Relationship Forms

With "regular form" I meant "Post Forms".
( the complete sentence was 'regular form to create a new post or edit an existing one' )

Here is a screenshot with a relationship field's option in a post form:
enlace oculto

And here is a screenshot with a relationship field's option in a relationship form:
enlace oculto

In case, you still see can't see these options in your form, you're welcome to share temporary admin login details, along with the page where this form can be seen.

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

#2101303

Thank you for sharing these details.

As, I explained in the first message, it is not possible to create/edit more than one relationship connection at a time, through a single form submit.

For this, you'll need to break down the setup into multiple steps:

1. You'll need a form to create a new VCards post on a page from where users can create them from the front-end. When the form is submitted, you can redirect the user to the newly created single VCards post page.

2. On the single VCards post page, you can add a post view that shows all the NFC-Chips posts, where the current user is the author.
(I understand that the admins will be creating the NFC-Chips posts for the users)

3. Inside this view, you can place a post form to edit the current NFC-Chips post in the loop. In this edit form, there will also be a field to select the parent VCards to connect to the current NFC-Chips post that is being edited.

This way user will not only be able to see all the available NFC-Chips posts where he/she is set as the author, but also edit which VCard post it should connect to.

I hope this makes sense and let me know if any point is not clear.

#2102043
Bildschirmfoto 2021-06-29 um 11.55.38.png

Thanks, as I understand I can still come around the limitations. Your idea is similar to what I use at the moment. Works so far:

- I have created a view for the nfc-chips and added relationship forms which works fine.
- I can now create relationships for the nfc-chips and connect them to the vcards in the frontend.

Unfortunately, toolset does not yet have an option to "edit" a relationship. Only to edit the metadata attached to a relationship. Therefore, I need to disconnect a relationship to be able to assign them to a different vcard.

Still, when I insert a "delete relationship shortcode" in the view for the nfc-chips nothing is rendered.

    [cred-delete-relationship role_items='$fromViews' relationship='profil-nfc-chip']Delete this relationship[/cred-delete-relationship]

See this link: enlace oculto

(I have renamed the vcard cpt to profile cpt)

Los hilos nuevos creados por Waqar y vinculados a este se encuentran a continuación:

https://toolset.com/es/forums/topic/split-how-to-delete-the-relationship-from-the-view/

#2103091

Should I open another ticket for this?

I cannot get the [cred-delete-relationship shortcode to work. Maybe you could have a look in the view mentioned.

Thanks in advance.

#2103097

Thanks for the update and I've created a new ticket about deleting the relationship from the view.
( ref: https://toolset.com/forums/topic/split-how-to-delete-the-relationship-from-the-view/ )

I'll perform some tests and will follow up on that ticket shortly.

You're welcome to mark this ticket as resolved.

#2103101

I found a solution in this post: https://toolset.com/forums/topic/i-am-trying-to-delete-the-relationship-using-this-code/

Had to create a child view with a "Query Filter" set to "Filter by post relationship or repeatable fields group owner" and select "items in the 'Profile NFC-Chips' relationship" as related items of "The current post in the loop".

Also I needed a "Post status filter" to "Select posts with status of publish or draft."

Still the linked documentation in the mentioned post is missing. The shortcode "cred-delete-relationship" is rather complicated to use and not documentation available afaik.