I have Toolset Views, Types, Layouts, Forms & Access all installed and configured. We created a simple directory where a user can submit their business listing on the website. The business listing has a custom post type.
We only want to allow the user to submit 1 business listing, so we used the following code on the "Add Listing" page, which works properly.
[wpv-conditional if="( u_post_count() lt '1' ) AND (( '[wpv-current-user info='role']' eq 'basic_member' ) OR ( '[wpv-current-user info='role']' eq 'premium_member' ))" evaluate="false"]You have already submitted a business to the directory. To edit your business listing, please click here.[/wpv-conditional]
To our question, is there any way we can have the "To edit your business listing, click here" link to the edit form, which is associated with their listing/post? So if I sign up as a new user and add a listing, there should be an easy way to modify the listing via a link in the navigation (i.e. Edit My Listing) and/or on "Add Listing" page?
Thank you for your feedback. I followed those directions and was able to properly have the edit form displayed on the actual post:
[wpv-conditional if="( '[wpv-current-user info="login"]' eq '[wpv-post-author format="meta" meta="user_login"]' ) "]
You have permission to edit this listing.
Please use the form below to make any necessary changes.
[cred_form form='edit-content-business-information']
[/wpv-conditional]
This is a bit of a pain though as the user would have to search through the entire directory to find their listing, then click on the listing to reveal the edit form. If possible, I would like to have either of the following:
1) A "Edit My Listing" link in the navigation, or sidebar, which links them directly to their post. Currently in the system, a user is only allowed to submit 1 business listing, so it should be a one-to-one relationship.
2) If the first option doesn't work, is there a way I can create another list view which auto-filters the business (custom post) associated with the logged in user? I can use this as a workaround..
You can see in the screenshot that there are various options when generating the edit link to change which post will be edited.
In your case we need to stick with the first one, but will need to create a View to set the right context for the current user.
So, make a new View to display the kind of post in question, and add a Query Filter so that the post author is the current user, so it will only show the post of the person that sees the View.
In the Loop Output section you would typically output fields from the post(s), but in this case you want to generate the edit link here (use the Fields and Views button). You may want to delete the No Posts Found text if you want nothing to appear for users that have not published a post.
You can then add this View wherever you want the edit link to appear.
If you want that to be in a sidebar, you'll find a Views widget you can use to insert it.
Thank you so much, that worked! Toolset rocks! I've been building WordPress powered websites for over 10 years, and this is the first time I've used Toolset and I'm beyond happy with all of the capabilities. Thanks again!