Skip Navigation

[Resolved] Display post modified author in Form

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to display the current post author inside an Edit Post Form, and when the User submits edits to the post I would like to set that User as the new post author.

Solution: Use the cred_save_data hook to programmatically set the post author when the Form is submitted. To display the current post author in the Form, use a Views shortcode like wpv-post-author.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-author

This support ticket is created 4 years, 1 month 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by richardB-16 4 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1869957

When I modify a post I want to display the WP author who last modified. Checked back end of the site and it doesn't appear to be capturing the author at all when I modify the post.

Do I need to create a field on the form that gets the author? Apologies I'm not great with this stuff!

#1870893

Hello, let me make sure I understand what you want to change and where you want to display the author information.

1. It sounds like you have a Form that edits some post. When someone uses the Form on the front-end of the site, you would like to display, somewhere inside the Form, information about the post author (whoever edited the post most recently, or created the post if no edits have been made yet).
2. When the front-end User submits the Form, you would like to store that User as the new, most recent, post author. That new User will overwrite the existing, previous modification post author, so whoever visits the Form next will see the new author's information.
3. I'm not clear about how this is related to or different from the post author in wp-admin. I assume you're talking about the same thing in both places, correct? In other words, you're not trying to store the modification post author information in some custom field value, but maintain the original post author in the actual, standard post author field, correct?

#1871469

Yes your summary is bang on - I already have the records showing and editable (two forms linked, but that's not relevant). It's a closed system so I can't link it publicly but I can provide you access if you want a look.

I've checked the back end of WP and it's not storing the author there either, which is weird. It was working a few weeks back before updates (I think).

#1871621

Okay thanks for the clarity. In standard setups, Forms will not modify the post author to be whomever edits the post. Normally that requires some custom programming using one of our APIs called cred_save_data to modify the original post author programmatically. So in general I would not expect the post author to be updated automatically without something like that added to your child theme's functions.php file, or in a new custom code snippet in Toolset > Settings > Custom Code.

You can see an example of this type of code here:
https://toolset.com/forums/topic/change-author-on-form-submission/#post-562725
You would need to adjust the numeric Form ID in that code to match your edit post Form's numeric ID. If you have some similar code on your site that is no longer functioning, I'll need to take a closer look.

To display the current post author inside a Form editor area using simple text, you can insert a Views shortcode inside the Form builder. In the drag-and-drop Form builder, you can use a custom HTML block to insert the Views shortcode. In the Expert mode builder, just paste the shortcode directly into the Form contents somewhere, something like:

Current author: [wpv-post-author]

That will render the current post author name inside the Form editor.

#1872923

My issue is resolved now. Thank you!