Skip Navigation

[Resolved] Letting logged in Users create posts with different CPT

This support ticket is created 5 years, 2 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 4 replies, has 2 voices.

Last updated by Waqar 5 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#1380049
siteground.PNG

Hi there!

My question is the following: How can I automatically link a proxy post to a logged in User, and make sure the User doesn't have to select his own proxy post, when filling in a form to create content?

What I'm trying to create is a website where trainers can create and display their profile, events and blogs.

I created a proxy post type for the trainers, and a CPT for the events and a CPT for the blogs. I also created a form where trainers can create an event, and another form for creating blogs. However, the problem is that the trainers have to manually link their proxy post to the CPT's (see screenshot). When a lot of trainers are on the website, it will get very messy. I would like to how to make sure that logged in users can fill in forms for creating posts, that are automatically linked to their own proxy post.

Thanks a lot for helping!

Greetings

#1380617

Hi Kerim,

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

To suggest the best way forward, I'll need to first see how the users are connected to their proxy trainer posts and how the forms for the events and blog posts are configured in the back-end.

Can you please share temporary admin login details, along with the information about how you're connecting a user to his/her proxy trainer post?

Note: Your next reply will be private and though no changes will be made on your website, please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1381699

Hi Kerim,

Thank you for sharing these details.

If you'll check the settings of the relationship field "Verbind hiermee je profiel aan de post", you'll see the option "Field default value".

Screenshot: hidden link

If you'll add the ID of the current user's "Trainer" post, it will be automatically selected/filled in the form and the visitor won't have to type it.
( as needed you can also hide this field from the front-end so that the pre-filled field is not visible in the form at all )

To get the ID of the current user's "Trainer" post, you can create a new post view, that is set to show trainer posts but with an author filter ( https://toolset.com/documentation/user-guides/filtering-views-query-by-author/ ), so that it only brings the post where the author is the current user.

In that new view's loop item content template, you'll only need the "[wpv-post-id]" shortcode, so that it only returns the ID of that post.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-id

To remove any extra spaces from this view's output, you'll need to take a couple of more steps.

There will be a checkbox for "Disable the wrapping DIV around the View" option, just above the "Output Editor" section on the view's edit screen.
( screenshot: hidden link )

Please check that option and the view's wrapping DIV container will be removed.

Also remove the shortcode [wpv-filter-meta-html] from it's "Output Editor" section and also remove all line breaks and empty spaces from the content in "Loop Editor" section, making everything in the same line.

Once this view is ready, you can place its shortcode in that "Field default value" option.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view

Important note: You'll also find useful information on linking users with their proxy trainer post type, in this guide:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1382873

Thank you very much!!!! It works 😀 😀 :D.

You've been a major help. Also with other tickets I submitted. As a token of my appreciation, I want to leave in a good review for you somewhere, but I couldn't find a general emailadres from the Toolset team to send it to. Can you provide that for me?

Greetings,

Kerim

#1383057

Hi Kerim,

Thanks for the update and glad that you found my messages helpful.

You're welcome to share your review about this ticket in the feedback form, after marking it as resolved.

Here are the links to our official social media profiles, if you ever want to publically share your general experience and testimonial related to our products and services:

hidden link
hidden link

For any new question or concern, feel free to start a new ticket - we're here to help!

regards,
Waqar