Title: After Import Actions
Last modified: January 23, 2017

---

# After Import Actions

 *  Resolved [joand](https://wordpress.org/support/users/joand/)
 * (@joand)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/after-import-actions/)
 * Hi [@capuderg](https://wordpress.org/support/users/capuderg/) – I hope all is
   well! We (Divi child theme developers) are running into occasional issues. As
   per the documentation, we have set up a function in the child theme style sheet
   to set the Home page, which works great. But sometimes we have somebody who wants
   to change that (e.g. I just had someone who wants to create a “coming soon” page
   while the site is in development.) They change it in their WordPress settings,
   but then the funtion changes it back to the Home page that we set! We tell them
   to delete those lines from the functions.php to get around it – but I am wondering
   if there is another way to code it so that the “after import” functions would
   only run after the “Import Demo Data” button is pushed, rather than every time
   the site loads?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Gregor Capuder](https://wordpress.org/support/users/capuderg/)
 * (@capuderg)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/after-import-actions/#post-8689343)
 * Hi,
 * the after import action is triggered only when the demo import button is clicked(
   at the end of the demo import progress). So, if set correctly, it should not 
   execute ever again, except if you import the demo again.
 * Either the after import action is not coded properly or something else is causing
   this issue.
 * Could you please show me, how you coded the after import action hook?
 * Take care!
 *  Thread Starter [joand](https://wordpress.org/support/users/joand/)
 * (@joand)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/after-import-actions/#post-8689444)
 * Okay, that’s good news! I must have it wrong (which means it can be fixed!) I
   actually think I see where I have gone wrong. This is what I have:
 *     ```
       /*Set Front Page from Reading Options*/
       $front_page = get_page_by_title( 'Home' );
       if(isset( $front_page ) && $front_page->ID) {
       update_option('show_on_front', 'page');
       update_option('page_on_front', $front_page->ID);
       }
   
       /*Assign menus*/
   
       function ocdi_after_import_setup() {
       	// Menus to assign after import.
       	$primary_menu   = get_term_by( 'name', 'Primary Menu', 'nav_menu' );
       	$secondary_menu = get_term_by( 'name', 'Secondary Menu', 'nav_menu' );
       	set_theme_mod( 'nav_menu_locations', array(
       		'primary-menu'   => $primary_menu->term_id,
       		'secondary-menu' => $secondary_menu->term_id,
       	));
       }
       add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' );
   
       wp_delete_post(1);
       wp_delete_post(2);
       ```
   
 * I should have everything inside of the function ocdi_after_import_setup – is 
   that right?
 *  Plugin Author [Gregor Capuder](https://wordpress.org/support/users/capuderg/)
 * (@capuderg)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/after-import-actions/#post-8690545)
 * Hi,
 * yes, that is correct [@joand](https://wordpress.org/support/users/joand/) 🙂
 * That will solve your issue.
 * Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘After Import Actions’ is closed to new replies.

 * ![](https://ps.w.org/one-click-demo-import/assets/icon-256x256.png?rev=2506685)
 * [One Click Demo Import](https://wordpress.org/plugins/one-click-demo-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/one-click-demo-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/one-click-demo-import/)
 * [Active Topics](https://wordpress.org/support/plugin/one-click-demo-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/one-click-demo-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/one-click-demo-import/reviews/)

## Tags

 * [demo import](https://wordpress.org/support/topic-tag/demo-import/)
 * [ocdi](https://wordpress.org/support/topic-tag/ocdi/)

 * 3 replies
 * 2 participants
 * Last reply from: [Gregor Capuder](https://wordpress.org/support/users/capuderg/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/after-import-actions/#post-8690545)
 * Status: resolved