Support

Account

Home Forums Front-end Issues Save post and change post status with same button

Unread

Save post and change post status with same button

  • Hello,

    I want to save the post and change the post status with the same button.
    Does somebody know how to create that function?
    I’ve made the function to change the status, it looks like this and that’s working.:

    function custom_save_for_approval(){
    	if('POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "declaration_submit_for_approval"){
    		
    		$declaration = get_page_by_path( $_POST['_wp_http_referer'], OBJECT, 'declaration' );
    		
    		// Update declaration status		
    		$update_post = array(
    			'ID' 			=> $_POST['postid'], 
    			'post_status'   => 'submit_for_approval',
    		);
    
    		// Update the post into the database
    		wp_update_post( $update_post );
    	}
    }
    add_action('init','custom_save_for_approval');
Viewing 1 post (of 1 total)

The topic ‘Save post and change post status with same button’ is closed to new replies.