Skip Navigation

[Resolved] Need help with Toolset Contractor style site.

This support ticket is created 2 years, 5 months 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
- 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)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 2 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#2208183
2021-10-28_21-57-33.jpg

Hello,

I am creating a directory site similar to Toolset Contractors but on a different WordPress niche and have certain queries:

1. Can you please outline what setup has been used for creating Toolset Contractor? A summary would suffice.

At my end, I have created the following:

CPT's:
i. Profiles (developer/designer's profile)
ii. Portfolio (websites created by the user)
iii. WP Components (list of WP themes & plugins)

Post Forms:
i. Create & edit user profile form.
ii. Create & edit portfolio items form.
iii. User registration form.

Relationship:
i. One Profile to Many Portfolios.
ii. One Portfolio to Many WP Components.
iii. One Profile to Many WP Components.

2a. How to limit the user so that they can create only one profile (post) per user account?

2b. How to set up the profile page such that if a user hasn't created their profile, the profile page would display a form to create a new profile (irrespective of the post status); and if the user has already created their profile, then the profile page would display a form to modify the profile?

3. In the following two scenarios, I am unable to create a repeatable Post Reference field which would allow the user to select the respective WP Components. Please refer to the attached image.

3a. I would like the user to be able to select the respective WP components (themes & plugins) that they are familiar with. For e.g. User A would be more familiar with GeneratePress; User B would be more familiar with Ocean; whereas User C would be familiar with both the themes. The user should be able to select all the themes & plugins they specialize in to for building any WP website.

3b. Similarly, when a user is adding websites to their portfolio, I would like the user to be able to select the WP Components used for building the respective website.

For both the above scenarios, I have created WP Components CPT in which I would add some of the most popular & widely used WP themes & plugins (like page builders, block builders, form builders, dynamic content builders etc.)

P.S. Just to make working with this support request easier, we can work on one point at a time. Once it is resolved, we can move to the next or whatever way you are comfortable with.

#2208721

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

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

1. Our Toolset Contractors section includes bespoke development, but, the main components or structure can be divided into these parts:

a). CPTs

- Contractor Profiles
- Contractor Portfolios
- Contractor Jobs
- Contractor Job Requests

b). Custom taxonomies

- Supported themes ( attached to the "Contractor Profiles" and "Contractor Portfolios" )
- Supported plugins ( attached to the "Contractor Profiles" and "Contractor Portfolios" )

c). Post relationships

- Contractor Profiles -> Contractor Portfolios
( one-to-many )

- Contractor Profiles -> Contractor Jobs
( one-to-many )

- Contractor Profiles -> Contractor Job Requests
( one-to-many )

- Contractor Jobs -> Contractor Job Requests
( one-to-many )

Every contractor role user will have exactly one "Contractor Profile" post, as a post author.

While creating a "Contractor Profile", the user can choose terms from "Supported themes" and "Supported plugins" taxonomies, to show which themes and plugins he/she is familiar with.

After creating a "Contractor Profile", the contractor user can also add multiple "Contractor Portfolios" posts, where "Supported themes" and "Supported plugins" taxonomy terms can be selected, to show which themes and plugins were used for this particular project.

The regular users on the website can add "Contractor Jobs" posts, to share information about the project they need to hire a contractor for.

The contractor users will see those "Contractor Jobs" and if interested, they can create a new "Contractor Job Requests" post, to let the project poster know that he/she is interested in the project.

Once the user approves a "Contractor Job Requests" post, that "Contractor Jobs" is awarded to that contractor.

I hope this structure makes sense and let me know if any point is not clear. We'll move to the next points, accordingly.

regards,
Waqar

#2208925

Hi Waqar,

Thank you for the detailed information.

Just to let you know, I made a few changes. I replaced the WP Components CPT with i) WP Themes & ii) WP Plugins CPT's respectively. Now the relationships are as follows:

Users to Portfolio — one user can have many portfolio items.
Users to WP Themes — one user can have many WP themes as their speciality.
Users to WP Plugins — one user can have many WP plugins as their speciality.
Portfolio to WP Themes — one portfolio item can have only one WP theme.
Portfolio to WP Plugins — one portfolio item can have many WP plugins.

In your setup, you mentioned that Toolset is using custom taxonomies for WP Themes & WP Plugins. However, in my case, I decided to use CPT's because I would also like to create posts to let the visitors know what the particular theme or plugin is all about.

Also, I forgot to mention that I won't be using the Job & Job Requests features at the moment.

We can now proceed to point #2.

#2211641

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

I recommended the use of custom taxonomies for the theme and plugins not only because it has significant performance benefits, but also because it will greatly simplify the attachment process.

For attaching multiple posts through CPT relationships, you won't be able to use the 'create new profile post form' and the 'edit existing profile post form'. Instead, you'll have to use a separate relationship form for each relationship, that will be able to create one post connection per form submission. For example, to connect 3 themes and 3 plugins to a user profile, the profile-to-theme relationship form will need to be submitted 3 times and the profile-to-plugin relationship form will also need to be submitted 3 times.

On the other hand, if you're adding themes and plugins as terms in their respective custom taxonomies, you'll be able to attach/manage them right from the 'create new profile post form' and the 'edit existing profile post form'.

If you'll use the taxonomies for the themes and plugins, you can still show information about an individual theme or plugin on its term archive page and taxonomy terms also support custom fields.

I hope this explanation also covers your concerns in point# 3.

2. To limit the user so that he/she can only create exactly one profile post, you can show the form to add a new profile post conditionally.

For example, you can register a custom shortcode that gets the user profile CPT slug in shortcode attribute "type" and can then return the ID of the profile post where the current user is the author and if no such post is found return 0 (which would mean that this user has not created a profile post, yet).

For example:


add_shortcode('current_user_profile_id', 'current_user_profile_id_func');
function current_user_profile_id_func( $atts ) {
 
    $a = shortcode_atts( array(
        'type' => '',
    ), $atts );
 
    $user_post = get_posts( array( 
        'post_type'     => $a['type'], 
        'author'        => get_current_user_id(),
        'numberposts'   => 1
    ) );
 
    if(!empty($user_post)) {
        return $user_post[0]->ID;
    }
    else{
        return 0;
    }
 
}

This shortcode can then be used in the conditional evaluations for whether the 'create new profile post' form should be shown ( when the shortcode returns 0 which means that user profile has not been created before ) or the 'edit existing profile post' form should be shown ( when the shortcode return an ID other than 0 which means a profile post has been created already ).

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