Skip Navigation

[Resolved] Split: How to change the post author when using a front-end edit form

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

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1196553

Also once they edit the form - we change the owner to them?

#1197070

Nigel
Supporter

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

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

You'll need to add some code that uses the Forms API to modify the post author once the edit form has been submitted and the results saved.

You can add code snippets at Toolset > Settings > Custom Code, where you can add the following:

add_action( 'cred_save_data', 'tssupp_reset_author', 10, 2 );
function tssupp_reset_author( $post_id, $form_data ){

	if ( in_array( $form_data['id'], array( 123 ) ) ) {

		$post = array(
			'ID' => $post_id,
			'post_author' => get_current_user_id()
		);
		wp_update_post( $post );

	}
}

You'll need to edit the ID of the edit form (123 in the example).

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