Skip Navigation

[Resolved] Trying to add Edit Button for front end user published custom post

This support ticket is created 2 years, 6 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: Africa/Casablanca (GMT+00:00)

This topic contains 9 replies, has 3 voices.

Last updated by Directory 2 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2183361

I am having several issues whilst trying to add an edit button and delete button for my front end user published custom post types...

1) Every time i try to add an edit button into the template loop it prompts me to create a new post form, even though i have already created an edit post form.

2) When i add the delete button it seems to add an additional delete button to the bottom of the page (clicking it causes the page that the view is being hosted on to be delete)

3) im using a view to do display posts dynamically like an archive, but its showing some of the archive entries in an unformatted way rather than in a grid

#2183711

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

You are listing posts using a View, and you want to display links to edit the posts or delete them, correct?

Let me list the steps required so that you can confirm you have done the same.

- You go to Toolset > Post Forms and create a form to edit the posts.
- You then go to Toolset > Content Templates and add a new template (give it a name), don't assign it to anything, but insert your edit post form here. (Edit forms needed to be added to a template to provide the right context.)
- Edit the page containing the View, and in the output section of the View insert a Fields and Text block. There you will see a small icon to insert Toolset Forms (or form links), where you can insert the link to edit the post using the edit form (you will specify the content template that contains the form).
- You can do the same (using a Fields and Text block) to insert the delete post link.

Does that match what you did?

#2191929

Hi,

Sorry for my late response . . .

Yes i have done all steps above and have managed to bring the add new form into my desired page but still not able to add edit button to form.

I have previously been told not to use block views as it is not fully compatible with wordpress

#2192171

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Would you allow us temporary access to your website to check this further? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

Please share a URL where we can see this view, or the direct URL to edit it/

#2193023

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

It seems that the view queries the posts that are created by the current user. The provided user does not have any posts right now. Can you please create enough posts for this user(Jamal) so we can see the issue(especially the last one as it will require multiple posts, right!)
Once the issues are visible to me, I'll do my best to help.

In the meantime, I have also checked the 1st issue(edit link), I assume that you are talking about this message for creating a content template, right? hidden link
Well, as you can read in the following article, you will need to create a content template where the edit form will be used https://toolset.com/course-lesson/front-end-forms-for-editing-content/
If you do so, the edit link will not point to this page hidden link
It will redirect to a URL similar to hidden link (where 1234 is the ID of the content template that holds the edit form.)

If you want to edit posts in this page hidden link you cannot use the Forms edit link. You will have to create your own link. Something like hidden link (where 456 is the ID of the post to edit)
And inside of the page, you must take this ID and pass it to the form using the post attribute:

[cred_form form="Name of the form" post="[wpv-search-term param='post-to-edit']"]

Read more about the wpv-search-term here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term

I hope this makes sense. Let me know if you have any questions.

Once, you reproduce the 2nd and 3rd issue, please reply here, and I'll check them further.

#2193119

Hello,

Thanks for your response. I have now added several sample books to Jamals account.

Both issue 2 and 3 seem to be resolved leaving only issue 1 and more specifically the redirecting to the relevant front end page.

are you saying it isn't possible to make the edit link a button and also isn't possible to send to custom frontend page ?

#2193713

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you for your collaboration.

You asked: are you saying it isn't possible to make the edit link a button and also isn't possible to send to custom frontend page ?
That's definitely not what I am saying. Well, to answer your questions:
1. If you want to edit the posts on a specific page, then you CANNOT use the Toolset Forms post edit link. Why? Because the post edit link will enforce its proper URL. Which will take you to a separate content template to edit the post. It won't take you to the page where you want to edit the post.
2. The post edit link shortcode accepts a "class" argument. You can pass a CSS class there, and add custom CSS code that will make the link appear as a button.
Read more about the post edit link shortcode here https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#toolset-edit-post-link

Now, if you want to use the post edit link, you will have to go with it:
1. Create a content template and put the form inside of it.
2. Add the custom CSS class and styles that will display the edit link as a button.

If you want to edit posts on a separate page:
1. You must build the links yourself as I describe in my previous reply.
2. As you are building the link yourself, you can make it appear like a button.

Does it make sense? Can you continue from here? Would you need further assistance? If yes, please let me know what you intend to do(use a separate page, or use a content template and the post edit link)?

#2193839

Ok i think i understood that time. . .

So i have stopped usigng the edit link, and made my own using ACF (reluctantly because i feel they offer a similar but less comprehensive package to toolset)

Now if you go to: hidden link and click the edit button it will take you to the relevant front end page however, the form view is not viewing . . . instead it is saying "Form type and post type do not match" ?

#2193939

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Because you are putting the form on the page, it will consider that you want to edit the page. The form is intended to edit a post from the "My Top 10 Books", that's why it displays the message "Form type and post type do not match".
If you put a views shortcode in the form, like the title shortcode(wpv-post-title), it will display the page title.

We'll need to pas the correct post_id to the form. And that can be done by Elementor by choosing the post. Check this screenshot hidden link

This method is limited to choosing a specific post. While we want to dynamically get the post from the URL. We could use the wpv-search-term to get the post ID and do something like:

[cred_form form="Edit Top 10 Book" post="[wpv-search-term param='post_id']"]

But, that can't be done inside Elementor. Elementor does not handle nested shortcode in the same way Toolset does.

So, we'll need to go through a Toolset content template to make sure that the nested shortcodes are correctly evaluated.
I created a new content template, without assigning it to any post type. The "Edit Top 10 Book" content template. hidden link
Inside of it, I put the shortcode inside a Fields&Text block:

[cred_form form="Edit Top 10 Book" post="[wpv-search-term param='post_id']"]

Then, I used the template inside the page, using an Elementor Text widget, with a shortcode. Check this screenshot hidden link

[wpv-post-body view_template="Edit Top 10 Book"]

And voila, I am able to edit the desired post correctly hidden link

Read more about the used shortcodes here:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
- https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/

I hope this helps. Let me know if you have any questions.

#2196191

My issue is resolved now. Thank you!

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