Skip Navigation

[Resolved] relationship forms

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 5 replies, has 2 voices.

Last updated by SJ5362 1 year, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2588139
Capture d’écran 2023-04-06 à 12.52.52.png

I am creating a "user page" and I am struggling with some relationship forms.

Let me explain first what I successfully achieved on this page :
- each WP user when they first arrived on this page need to create a profile (which is a CPT)
- They can also edit this profile and everything is working great so far.
- Now, every profile is in a "many-to-many" relationship to a/some "company" (here "societe" in French)
- No problem creating those relationship through the WP interface or even through a relationship form (!).

- but then I want to "list" every companies the profile is linked to ... and I am struggling.
- To summarize whant happens on the page :
• I have a first view to "select" the profile which belongs to the logged in user (view-member-profile-for-logged-in-user-with-nested-view-for-relations)
• This loop (only one item but still a loop) is displaying a template called "FV_template_profile-s-societe"
• This template is itself displaying a view to "list" all "companies" in relation with the profile (name is : view-relations-for-profile-inside-nested), and this loop -working correctly- displays all related companies. Great.
• Now is the problem : I'd like this companies list to be "editable" : I'd like to be shown, not just with their name but I'd like to be able to change / delete them. I'd like them to be listed in the same way they were added. that why I used the same form relationship but everything is mixed up now (parent and child are switched, etc.). Maybe because we are in a loop, looping companies (??).

Please help. I have been working on this for 5 hours, I am getting exhausted.
(On the picture you see the form 3 times). the first two shows my existing relation (the companiesrelation with my profile) though the names of the companies should be in the "société" field, not "member" (!). And the third form is the form to ADD a relation to a company (and this one is working well and displaying well).

Maybe you'll need a way to log to check those things.

(PS : I have read a lot of doc on your side already).

#2588563

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Do you mean that you want to first list all the related companies belongs to profile as list and offer user Edit link so that user can edit the connection or even delete the connection?

Can you please share problem URL and admin access details and let me review your current settings. Please share your exact workflow you want to achieve (maybe few screenshot that will help).

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

#2588763

Minesh
Supporter

Languages: English (English )

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

I've review the screenshot you shared and that is not possible how you want as every connection is different and we can not merge all connection to one. We will have to use post relationship form and edit link and view to display related companies.

Once you setup test data please get in touch with me and I'll show you whats possible.

When I try to access the frontend link: hidden link

The layout of the site is broken I'm not sure why - Can you please correct that.

Also, could you please setup a test profile (which I think is already available when I login using: yoann@fokusmap.com ) and add few companies and just send me the link of the page where you are displaying related companies.

#2588971

I'd like to be sure to understand you correctly so i'll try to rephrase :
- "merge all connection to one" : ..... I am not sure myselft that this is what i wanted to do ..... if we have to do with an edit link, that is fine with me, we'll just have to change the design and that's it !
- Site broken : it is repaired now.
- test data : the test account is yoann@fokusmap.com. It is linlk to one "profile" (CPT) that is itself linked to 2 companies (Sofra Inox and Fraenkische)
- test profile : .... same answer yoann@fokusmap.com
- link to page where I am displaying related company : i've just create this page -since you said we needed an edit link : hidden link. though I really don't know how to go further

Thank you Minesh !

#2590457

Minesh
Supporter

Languages: English (English )

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

I've created the following custom shortcode that will return the current loggedin user member post ID. I've added the following code to "Custom Code" section offered by Toolset:
=> hidden link

function func_get_author_post_id() {
 
    $user_id = get_current_user_id();
     
    $args = array(
        'author'        =>  $user_id,
        'post_type'     => 'membre'
        );
    $my_post = get_posts($args);
  
    if(!empty($my_post)) 
        return $my_post[0]->ID;
 
}
add_shortcode( 'get_author_post_id', 'func_get_author_post_id');

Then I've created the following view that will get the related companies belongs to the current loggedin user member profile post ID. The following view displays the post title, edit form link and delete link. You can customize it as required.
=> hidden link

Then I've created the following content template and added the above view:
=> hidden link

[wpv-view name="companies-belongs-to-profile" wpvrelatedto='[get_author_post_id]']

Then I've added the above content template to your divi page builder's text block:
=> hidden link

[wpv-post-body view_template="ct-to-hold-company-belongs-profile-view"]

This is how you can display it and possible way.

#2591807

My issue is resolved now. Thank you!