Skip Navigation

[Resolved] Relationships and more

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

Last updated by Minesh 1 year, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2698330

I asked you these pre-sale questions about a week ago. Thinking I would hear back from you soon, I went ahead and purchased toolset. I was wrong, never heard back from you. I'll try one more time.

I am building a directory and classified for members of different churches. Each user will create one directory listing, Or user profile, searchable by name or church. Each user will create many listings for classifieds.

Every plugin I've ever used makes the user users input contact and address info over and over for every listing they create. I want to create ONE address, church and contact info in the user profile and then when user's create listings, I want to pull queries on listings based on the user's address, not have to insert it every time a user creates a classified listing. Since user's and posts are already related do I need to create a new relationship?

In a perfect world this is how the process would work -

1. User will create a profile (or directory listing) and insert address and church (taxonomy or custom post type?).
2. User will create classified listings and queries can be pulled for listings based on authors address or church. If this cannot be done and the church and address fields need to be part of the listing, then perhaps when a user creates a listing the default church and address could be pulled from user or directory?

I've been planning to use taxonomy for churches. Or do you suggest I use CPT?

I'll be willing to pay for custom programming if necessary.

Lastly, I'm also creating an academy for the users. Currently using multisite, and planning to use Tutor LMS and a subsite for the academy. Do you recommend this or should I use one site and tutor lms theme for everything? If not, do you recommend any specific theme?

Thank you so much,
James

#2698597

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Frist of all - here is the recommended themes for Toolset based sites.
- https://toolset.com/documentation/recommended-themes/

Its your own choice how you would like to structure your content. With every structure you decide it will have its own advantages and disadvantages and you will have to decide what way you would like to go, its your personal choice:

Regarding - directory site site, we offer full course:
- https://toolset.com/course/wordpress-directory-and-classifieds-sites/

Here is how you can make relationship with user:
- https://toolset.com/course-lesson/how-to-create-custom-searches-and-relationships-for-users/

Another idea would be you can also create custom post type "User Profiles" and when user register it will add a one entry to this post type that means each user will have a one user profile post and you can use this custom post type to build post relationship with other post types.

Even we offer a free test platform http://www.discover-wp.com where you can use and play with the available referent site and check what's available and what other requirement you want to add:
=> https://discover-wp.com/site-templates/

Even you can use Framework Installer plugin to install any of the reference site on your local server:
- https://toolset.com/course-lesson/using-framework-installer-to-install-reference-sites/

I suggest you can use any of reference site we offer and create a test site build on top using Toolset that will help you to understand what and how you can build things using Toolset.

#2699351

Thank you so much. I will look at the user relationships. Here is what I have done so far...

Created two different CPT - directory and listings. I plan to use directory the way you explained user profiles. I have a one to many relationship with directory and listings.

I've built a directory page with a search, sort, and display view. This view can be searched by church, name, or city. I have distance field inserted for search. In order for search to work user must type in address or ckick on "use my location". Is there a way to store a user address the distance fucntion can refer to instead of making them select a location everytime? I would like all searches to default at 25 miles and remain this way unless user changes distance. I want it to remain this way even when all filters are cleared. In the rare event a user needs to search more than 25 miles they can clear it or change it then. But all default searches would remain ar 25 miles. Is this possible?

Since I have directory and listings related - I am building this for church members and i am hoping to somehow create a query view which allows to search for "listings" based on church or address in "directory". Is this possible? Otherwise user must enter same church and address over and over for each new listing. It's like having to enter your email, name, and social links over and over again. I want these fields in directory but need to search the listings that are attached to them.

I'm currently using Astra theme. I'll look at your preferred themes.

Do I need to be concerned with user relationships since I already have a directory relationship? Also, users do not allow taxonomy and im using taxonomy for church name. So that may be another good reason to stick with directory type?

Thank you!

#2699529

Minesh
Supporter

Languages: English (English )

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

I've built a directory page with a search, sort, and display view. This view can be searched by church, name, or city. I have distance field inserted for search. In order for search to work user must type in address or ckick on "use my location". Is there a way to store a user address the distance fucntion can refer to instead of making them select a location everytime? I would like all searches to default at 25 miles and remain this way unless user changes distance. I want it to remain this way even when all filters are cleared. In the rare event a user needs to search more than 25 miles they can clear it or change it then. But all default searches would remain ar 25 miles. Is this possible?
====>
There is no way to store the user location but as you can see that there is option to filter the results based on the user's location.

Please check the following Doc that shows information about how you can modify or set the default distance radius:
-- https://toolset.com/course-lesson/filtering-and-ordering-map-markers-by-distance/

Since I have directory and listings related - I am building this for church members and i am hoping to somehow create a query view which allows to search for "listings" based on church or address in "directory". Is this possible? Otherwise user must enter same church and address over and over for each new listing. It's like having to enter your email, name, and social links over and over again. I want these fields in directory but need to search the listings that are attached to them.
===>
Basically - you can build custom search and add custom search frontend filters to view for the fields that are attached to post type you set to query.

For instance - if you have post type "Book" and "Book Author" where you added the custom fields "Book Name" and "Book Status" that belongs to "Book" pot type and "Author Name" and "Author Description" that belongs to "Book Author" post type.

Now, when you create a custom search view for post type "Book" you can only add custom fields that belongs to post type "Book" that means you can filter the view results by adding custom search fields "Book Name" and "Book Status".

If you created a post relationship between your post types - you may copy the values of church and address while you create new post or update post of listing post type so those values automatically copied from the parent post. Does that makes sense?

However, I would suggest first you create your structure and add some domo content and then send me for review and once I review your current structure and requirement of your custom search I will be in better position to guide you in the right direction and I will see if I can offer any workaround for the same by adding view's hooks and filters.

Do I need to be concerned with user relationships since I already have a directory relationship? Also, users do not allow taxonomy and im using taxonomy for church name. So that may be another good reason to stick with directory type?
===>
You can try and check and play with it and see what will be the better resolution for you.

I urge you to create a new ticket with every new question you may have. This will help us to write problem resolution summery for the original query reported. If required, when you create the new ticket you should add the old ticket link as reference.

#2699987

I've learned if a user clicks on "my location" button before doing any search, it will do a search based on the user's current location and the default radius miles. Knowing this, I'm using search fields, no submit button, and using the "my location "button as a search button. I renamed it to search. I'll create a user url field and teach user to copy and paste a default search url in this field. I'll then create a button which redirects to this user's url default search url. This will ensure users always start off with a default search, knowing they can reset at any time. The link is here hidden link.

It is very difficult to style these fields, especially the distant field in the views. I'm very surprised at how useless Elementor has been when it comes to styling? If I create an elementor page it makes my link to the views and still gives me no styling advantage?

Regarding my Directory/Listings relationships - If I understand you correctly, you're suggesting I may need to automatically copy the user's address and church data into new listing address and church field? I suppose I can, but again, this is a lot of duplicate data for every listing? I've tried to build a view to display listings with addresses and churches from the directory CPT but I have not been successful. That page is here hidden link.

Thanks

#2699988

Wrong Links

hidden link

hidden link

#2700126

Minesh
Supporter

Languages: English (English )

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

Ok - in what format you want to display address and church. you want to group by what?

Can you please share all those required details and problem URL send me admin access details.

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

#2701796

Minesh
Supporter

Languages: English (English )

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

That thing is that you can add frontend filter for custom fields or taxonomies to the view for the post type you set your view to query.

If you set your view to query post type listing - you can add frontend filters for custom fields and taxonomies that belongs to post type listing. In your case the "church" taxonomy belongs to parent post type Members so its not possible.

However - there is possible workaround and easiest would be you should add/assign taxonomy "church" to post type "listing" as well (including member post type) and then when you add/update new listing post - you need to make sure that you should copy the assigned terms to members (parent) "church" taxonomy to the listing "church" taxonomy.

Then it will give you luxury to add the taxonomy filter church to your listing post type as church taxonomy is assigned to post type listing and we already copy the parent term to child post.

I hope this makes sense.

If you are ok with this idea, I would like to know from where the listing posts are added/updated.

#2701879

I understand you are saying to add church taxonomy to listings then when a new listing is created we can copy church taxonomy. How Do I copy it? I assume this means the user wont have to enter the church each new listing that it will be added automatically by copying? How DO i do this?

So far i see no benefit to having a relationship with members and listings. If user must enter this data over and over anyway.

I have a form for adding listings, but it is not finished until i know how to do what you are describing. And again, i think adding the same church to every listing every time is not good. I mean, why not add the user's email and password to every listing? It is overkill.

But if my only solution is to enter this same data over and over then I'll need to know how to copy the member church to new listing search.

Thank you

#2701881

Minesh
Supporter

Languages: English (English )

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

You need to tell me from where you are adding listing? Is it from frontend or backend?

I know its not the optimized result but this is how it should work there could be other possibility but as you have multiple filters added and one of them is address (location) search I suggest you should go with the solution I described.

Once you tell me how you add/edit listings and if you are using Toolset forms - what forms you are using and send me those links I will be able to guide you in the right direction.

#2701901

I want to add the listing on the front end. I have not finished the form yet because i do not know how to do what you are suggesting.

Form is here - hidden link

#2701986

Minesh
Supporter

Languages: English (English )

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

This is the parent post and as you can see to this parent post "James A. Smith" the church assigned to is: Palmetto, FL and FBC Palmetto.
- hidden link

To your form - I've added the relationship field so when you add listing we can connect to what parent post it belongs to:
- hidden link

As you can see it shows the relationship field "Directories Listings" on frontend:
- hidden link

We used the Toolset Form's API hook "cred_submit_complete" in order to copy the parent post taxonomy terms to child post.
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_submit_complete

To get related parent post ID - we use post-relationship API function toolset_get_related_post():
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

I've added the following code to "Custom Code" section offered by Toolset:
- hidden link

add_action( 'cred_submit_complete', 'func_copy_parent_term_to_child_post', 99, 2 );
function func_copy_parent_term_to_child_post( $child_id, $form_data ){
 
    $forms = array( 511 ); // ID(s) of forms
    $taxonomy_slug = 'church'; // taxonomy slug
    $relationship_slug = 'directory-listing'; // slug of relationship
 
    if ( in_array( $form_data['id'], $forms ) ){
      
  		//// getting related parent ID
        $parent_id = toolset_get_related_post( $child_id, $relationship_slug );
      
      	/// getting parent post terms
      	$parent_terms = wp_get_object_terms( $parent_id, $taxonomy_slug, array('ids') ); 
        $parent_term_ids = wp_list_pluck( $parent_terms, 'term_id' );
      
      	/// copy parent post terms to child post
   wp_set_object_terms( $child_id, $parent_term_ids, $taxonomy_slug );
    }
}

Now, you should try to add new listing and select the related parent post from the relationship field "Directories Listings":
- hidden link

Once you submit the form and check the new listing you created, you will notice that it will automatically copy the parent terms to listing you created.

More info:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/