awesomemotive / one-click-demo-import

One Click Demo Import plugin
https://www.awesomemotive.com/
195 stars 83 forks source link

Redirect after import complete #187

Closed Nanosergio closed 4 years ago

Nanosergio commented 5 years ago

Hello! Thanks for your great plugin! I want to redirect the user to their main page when the plugin finishes importing to visualize the result. I used the hook pt-ocdi/after_import to redirect

function ocdi_after_import() {
    wp_redirect ( home_url() );
    exit();
}
add_action( 'pt-ocdi/after_import', 'ocdi_after_import' );

but it displays a notice block with the landing page.

<div class = "ocdi__response js-ocdi-ajax-response">
<div class = "notice notice-error is-dismissible">

How to redirect the users after import?

Lenny4 commented 5 years ago

I never used this plugin but you might use the wrong hook. Try to use pt-ocdi/after_all_import_execution. Found in this file one-click-demo-import/inc/OneClickDemoImport.php line 371

Nanosergio commented 5 years ago

Lenny, thank you very much for your message but the result is the same. A notification block appears displaying the destination page (home).

odci  capture 1 odci  capture 2

capuderg commented 4 years ago

Hi @Nanosergio,

sorry for the late reply.

You could hook into the JS/jQuery custom event ocdiImportComplete that we trigger at the end of the import AJAX call. You could use JS redirect when this custom event is triggered. So the solution would be totally JS based.

Take care!