Especially I've tried to prevent user from creating more than one custom post from a front-end form post as explained in the above mentioned course. The post is a business profile that must be unique.
I think I succeeded but I've noticed that it works only if the created post is published.
If you set up the post form to create a post with a status 'Pending review' it doesn't work for me: the post form is available more than once and user can create as many posts as he want to.
Could you confirm or did I make a mistake.
For my project, as created post must be validated by an admin, I would prefer it is saved as Pending review.
I can confirm that it is checking if the user has posts that are published. If the user's posts are not published then they can create another post.
Perhaps you can try adding a post status query filter to the view to let it include posts that are pending as well. This should help as the view will check for posts that are published by default.
Unfortunately I could not manage both the publication of just one post and the Pending status.
What I did not mentioned is that I would like the user to be able to view and modify his post profile even if it is still in Pending status.
For now I can't do that if the post is Pending. it must be published.
Sorry for not being able to give you all the information at once.
I would like profile posts, created from front-end post form, to be revised and approved by an admin before being visible in the site.
My idea is that if a post is approved, the admin change the status from pending to published in the back-end.
With the use of a third party plugin like BNFW a notification is sent to the author to let him know his profile is published.
What you can do is to output the Edit Form in the view.
Lets say the user already created the account but the profile is in Pending. If you add the query filter to the view to filter it by the Post Status then you can now display the Pending Posts in the view.
Instead of displaying any post data you will display the form. Or you can add a conditional block in the view to check the status of the items being displayed.
So if the post status is Pending then you will display the edit form directly, however if the status is Published then you'll display the Profile but an edit post link that will then allow the user to edit their profile even after it is published.
Thank you for your reply.
It is a great idea but unfortunately it doesn't solve the fact that a subscriber can still create as many profile posts as he wants to if profile post is in pending status (for example if he goes back to the url of the profile creation form).
The solution to display the profile creation form if no result is found in the view (as explained in the demo: https://toolset.com/lesson-placement/lesson-placements-1622969-1929573/?utm_source=pocket_mylist) only works if profiles are published.
I tried again.
I didn't understand that I didn't need a page containing the professional profile (custom content type) creation form.
This is how I managed to get closer to the result I want:
- creation of Toolset forms for creating and editing the professional profile
- in a page creation of a view for professional profiles with 2 filters
'Select posts with the author the same as the current logged in user' and 'Select posts with status of publish or pending'
- addition of the shortcode referring to the form for creating a professional profile if the view does not contain any data (loop template metabox)
- in the view loop, addition of a condition that tests if the number of items in the view is > = 1 (as you suggested)
in this case display of a content template containing the professional profile with a link to edit it
I hope it's not too convoluted.
Please let me know what you think of this.
Regards,
Simon
According to my tests the user can actually create only one profile.
Since the creation form is not attached to any page and does not have a url, I do not see how the user could access it.
I hope I am not mistaken.
I am closing this ticket for now.
Thank you again for your help.