How to Prevent logged out posting auto save feature

We recommend using the Code Snippets plugin.

Our system has a feature that when a user enters data it is auto-saved in the background so it's not lost and a user can return to work on it later if they are called away or have computer problems.  For logged-out users this will register a user BEFORE a user submits the information, some users have expressed that they do not want this to happen.  

The below code snippet will disable the autosave feature for logged-out users only, the listing and user will only be created when the user clicks the submit button.

add_action( 'init','_prevent_logged_out_auto_save');
function _prevent_logged_out_auto_save(){
	if(!get_current_user_id()){
		remove_action( 'wp_ajax_nopriv_geodir_auto_save_post', array( 'GeoDir_AJAX', 'auto_save_post' ) );
	}
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us