Skip Navigation

[Résolu] Making use of the "user" post in relationship to CPT

Ce fil est résolu. Voici une description du problème et la solution proposée.

This support ticket is created Il y a 7 années et 11 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 8 réponses, has 2 voix.

Last updated by AndreG3332 Il y a 7 années et 9 mois.

Assisted by: Minesh.

Auteur
Publications
#403696

Hi I am busy looking at a bit of a complex custom post type. I need some guidance in how to handle it.

This will be for an online advertisement site.
The basics is as follow:
Client will buy a package deal for advertising space. (done via Woocommerce) no problem)
Each package deal will offer a few different options as to the amount of space allocated. This is where my first question comes in.
The 1st package ad1
will allocate eg 1 space
The 2nd package ad2
will allocate eg 2 spaces ETC
The client will load their own add onto the system with a cred form. The spaces availabel to load the jpg adds must be limited by the package they select. With the forms you can select one or multiple instanced of file uploads to be used. Is it possible to limit it to the value that will be determined by the package deal (ad1 or ad2) they select.
Second point as far as i can see you can not user a user as a parent relationship with a custom post type. The problem this creates for me is as follow:
When a client log in i need the client to access their and only their adds so that they can maintain their adds. The problem is that without creating a relationship with a user how will i be able to do that?

My database structure will look something like this:

Data base name (relationship status)

User profile(one to one Advertiser)

Industry (one to many Advertiser)

Advertiser(client) (one to one Classified; one to one Business cards; one to one VIP advertising; one to many Block adds; one to many promotional. The question above will relate to the last two (black adds and promotional)

Classified add ( this be limited to one text based post only)

Business card ( this be limited to one imaged based post only)

Block adds ( this be limited to multiple imaged based post depending on the package deal opted for)

Promotional ( this be limited to multiple imaged based post depending on the package deal opted for)

So what I am hoping to achieve is that then client login with their user, their account details show up for editing purposes and that all the adds loaded show up on one screen.

I am relatively ok with creating the correct types and views etc for this and creating the correct cred forms. My problem is thus:
Showing the correct advertiser account depending on the login details and limiting the amount of adds ( block adds and promotional) depending on the package deal taken.

#404024

Minesh
Supporter

Languages: Anglais (English )

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

Hello. Thank you for contacting the Toolset support.

You can use the custom field to set up the limit per package for example field name should be "package_upload_limit" and using CRED form you can update the custom field "package_upload_limit" as per the selected package.

To limit the number of uploads it will require some custom programming where you should have one hidden variable that contains the "package_upload_limit" value and restrict the upload using jQuery or using CRED API validation hook. Please note both require some custom programming.:

CRED API validation hook:
https://toolset.com/documentation/user-guides/cred-api/#cfv

Usign jQury:
https://toolset.com/forums/topic/limit-number-uploading-files/#post-335393

Regarding displaying the current logged in user ads - it will be easily done using views and you can filter the view by logged in user or use [wpv-current-user] shortcode to get info about current logged in user.

What I would suggest is actually a mix of different forms, which are conditionally displayed with Access according to the Role.
https://toolset.com/documentation/user-guides/access-control-for-cred-forms/

You may also try to use the different form for the different package. Each Form creates the same Post Type eventually, but would hold different Fields (as example a single instance Media field for Role A and a repeatable instance for Role B)

On Role B CRED forms you apply a Custom CRED API validation to check the repeatable instance is not greater than 5 or any amount of instances.

To let the user buy a package you will need yet another Form, as elaborated here, you need a CRED Form for each Product / package you want to let the user pay the additional uploads with:
https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/

Also, actually the user should hold a Custom Field, so you can additionally evaluate by this field if the user is allowed to upload more images (after a purchase), otherwise, it will simply keep the Role evaluation and never let the user upload more images.

Also, this would require a Custom CRED API code to update the User Meta on the fly when you submit the payment form.
For this you will use this Custom API function:
https://toolset.com/documentation/user-guides/cred-commerce-api/

More info:
https://toolset.com/documentation/user-guides/cred-user-forms/
https://toolset.com/documentation/user-guides/charging-payments-with-cred-to-register-users/

#404061

HI MInesh,
Thanks for your very detailed reply to my inquiry.

If it is ok I would like to keep this thread open for a while while i am busy working through the solution in case I may need further assistance. It way take me a week or two as I am doing this project in between my other projects.

#404064

Minesh
Supporter

Languages: Anglais (English )

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

The ticket will be automatically closed after 30 days if it does not get any reply.

But I would suggest that kindly open a new ticket for your each new question as this will help other users searching on the forum.

Thank you for your kind understanding.

#404071

Thx Minesh. I will keep in mind. If it is same topic related i will keep it here but if it is outside the scope of this question i will post a new topic.

#404073

Minesh
Supporter

Languages: Anglais (English )

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

Ok great!!

#406571

Hi Minesh,

Hope you are well.

My first issue right now is i need to create a relationship between the user post type and a cpt named advertisers. it seems that the challenge is that the one is a custom post type (advertisers) and the other is a system post type, and I can not find a way to create a relationship as there are no system post types available in the linking option.

How do I go about doing that?

I assume that would be necessary to do if i want to do some of the filtering later where the user can only access the company and advertising details allocated to that user .

#406578

Minesh
Supporter

Languages: Anglais (English )

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

You cannot link users directly using Types relationship.

As I explain you in my previous post, you can use Toolset Access plugin to control the access for different roles.
https://toolset.com/documentation/user-guides/#access

For One to Many relationship - see this tutorial:
https://toolset.com/documentation/user-guides/getting-started-views/part-8-one-many-relationships/

For Many to Many relationships - see this tutorial:
https://toolset.com/documentation/user-guides/getting-started-views/part-9-many-many-relationships/

There are nice example and tutorials given.

You can learn using this example for many to many relationships as well:
https://toolset.com/forums/topic/how-to-create-a-relationship-from-1-child-to-2-parents-of-same-post-type/#post-300667

I suggest - You should go through our dcumentation;
=> https://toolset.com/faq/how-do-i-associate-one-child-with-several-parents-of-the-same-type/
=> https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

#415380

Thx Minesh, Working through ti all Will start new support line if I need to.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.