Skip Navigation

[Resolved] Change author of relationship post with a button in WP dashboard

This support ticket is created 5 years, 8 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 5 years, 8 months ago.

Assisted by: Beda.

Author
Posts
#1235973
screen-1.jpg

Hello,

I want to make a claiming process on the page. I have 2 types of a custom post. Business listing is the acctual listing and Claimed listing (CRED form to trigger claim request). Claimed listing post type is only a request which tells the logged in user and the listing which he claims. In the admin area I have all the needed data, now I want to change the Business listing author from the claimed listing post edit page. I want to add a APPROVE button which changes the author.

The printscreen show the table of the business listing in the claimed listing post. On the last place I would like to add the button.

Is this posible only with toolset?

#1236507

From within the WP Admin (backend), this is not possible without a Custom Code.
You would need to hook in the save_post() action of WordPress with a priority of at least 30 and do your custom actions within that hook.
We cannot provide help for such code.
It would also require to add the Button (HTML) which we cannot help with either.

Here is some Documentation that can help further:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/

I rather suggest creating a Toolset Form (Front End) where when you press the submit button named "Approve".
This form could for example edit listings or the claim directly, but not feature any of its fields so it cannot really be altered.

Toolset Forms also has an API with which then you can alter the post author it applies to (or any other, even related post if you want).
The API you'd use is cred_save_data() (this happens when the data is saved in the database) and you'd use wp_update_post() to update the author.
This is the DOC you can follow here:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://codex.wordpress.org/Function_Reference/wp_update_post

If you need to update a post that is related with Types to the currently edited post, you might use toolset_get_related_post to address the proper post:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

There are plenty of examples already in our forum on how to change the post author within a Toolset Form using the API:
hidden link
A good example:
https://toolset.com/forums/topic/change-author-on-form-submission/#post-562725
That will update the post with the current user as author.

We at Toolset Support can help you revise the code you write, explain how to use WordPress and Toolset API, and give example samples, but we cannot craft ready-to-use code for you.
If you would require such ready-to-go code or need professional assistance in coding, we can suggest contacting a Contractor here:
https://toolset.com/contractors/

Please let me know if you'd need more help on this task, or other details.