Skip Navigation

[Resolved] Use postype to duplicate user info and make advanced sorting

This thread is resolved. Here is a description of the problem and solution.

Problem:
Use postype to duplicate user info and make advanced sorting - how to create post automatically when creating user

Solution:

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/use-postype-to-duplicate-user-info-and-make-advanced-sorting/#post-1365173

Relevant Documentation:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created 5 years ago. 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.

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

Last updated by Pat 5 years ago.

Assisted by: Minesh.

Author
Posts
#1364209

Pat

Heelo,

I'm working on a site that offers members to search for other members with some specific parameters. I have seen this topic :
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
but I'm not sure to understand how this is working.

Here is what I would like :

- Users can create their account on the site
- In addition to the standard info (firstname, lastname, mail ...), they are able to define some parameters (birth date, address, ...
- All the parameters can be used to make searches for users in the whole site
- A user can modify his own parameters (and his standard info)

Do you think the above link is able to help for my specific needs and explain a little more in detail how I need to proceed.

Regards
Pat

#1364217

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Basically, You can build custom search with post type views and post type archives. You can not build custom search with taxonomy or user type views.

So, if you want custom search with filters you need to have post type that holds the user information. And then you should try to follow the Doc:
=> https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/

- All the parameters can be used to make searches for users in the whole site
==> if you create a post type that will hold the user information and create a view, you can filter and search within the post type to which view is set to query.

- A user can modify his own parameters (and his standard info)
==> You can use the Toolset User form to edit user profile and Toolset post form to add/edit entry for post types.
-- https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-creating-content/

#1364285

Pat

Hi Minesh
Thanks for this clarification.
I'm just wondering how to manage the user creation as part of the info will be on the user meta and the others will be on postype
Is there a way to do it in one shot (I don't want user have to create their basic account and need to come back to fill all needed info related to the postype).
Any idea?
Regards
Pat

#1365173

Minesh
Supporter

Languages: English (English )

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

You need to use the Toolset Form's hook: cred_save_data

Please check the following related ticket:
=> https://toolset.com/forums/topic/automatic-post-creation-on-registration/#post-555275

When new user created - you should create a new post automatically using wp_insert_post() function.
=> https://developer.wordpress.org/reference/functions/wp_insert_post/

More info about our cred_save_data API here:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#1365181

Pat

Hi Minesh,

So I presume I need to work the following way :

1. Create a user form to collect all needed info
2. Setup a cred_save_data to create the related post
3. Make the same to update user data by the user

It seems that concerning point 3, the best way is to store all user info as user meta first and use the cred_save_data to duplicate (for creation or modification) in the post. The hook should be a little different as in case of creation, I need to use the wp_insert_post(), but in case of modification, I need to use wp_update_post().

Let me know if this seems the right way to manage it.
Regards
Pat

#1365273

Minesh
Supporter

Languages: English (English )

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

Yes - actually you should have a USER form and then use the Form hook cred_save_data to insert new post with all user information to post type you will create and insert the post using the function wp_insert_post().

#1367335

Pat

My issue is resolved now. Thank you!