admin管理员组

文章数量:1122832

I'm quite newbie in PHP and plugin development, and I think I'm missing something obvious but I dont know how to do it.

When I activate my plugin (it adds some menu items), everything it's ok except I have to refresh the page to see those items, I that that items appers automatically when the plugin is activated.

I have this to run on activation hook (do I have to add something inside that hook):

Thanks

//////// Run on activation
function to_do_on_activation() {

    cgs_create_page();
    set_static_front_page();
    cptui_register_my_cpt_frontiles();
    cptui_register_my_taxes_tiles_categories();
    insert_term();
    cgs_create_tiles();
    cgs_create_page();
    set_static_front_page();
    updateTheme('Creative_Grid');
}

register_activation_hook( __FILE__, 'to_do_on_activation' );

No I realize that there is an error when activating the plugin with TGM plugin that it's interfering in the normal process of activation (refreshing the page).

The plugin is activated but I have this warning "The plugin generated unexpected output."

I'm quite newbie in PHP and plugin development, and I think I'm missing something obvious but I dont know how to do it.

When I activate my plugin (it adds some menu items), everything it's ok except I have to refresh the page to see those items, I that that items appers automatically when the plugin is activated.

I have this to run on activation hook (do I have to add something inside that hook):

Thanks

//////// Run on activation
function to_do_on_activation() {

    cgs_create_page();
    set_static_front_page();
    cptui_register_my_cpt_frontiles();
    cptui_register_my_taxes_tiles_categories();
    insert_term();
    cgs_create_tiles();
    cgs_create_page();
    set_static_front_page();
    updateTheme('Creative_Grid');
}

register_activation_hook( __FILE__, 'to_do_on_activation' );

No I realize that there is an error when activating the plugin with TGM plugin that it's interfering in the normal process of activation (refreshing the page).

The plugin is activated but I have this warning "The plugin generated unexpected output."

Share Improve this question edited Jan 20, 2015 at 12:51 Dedalos01 asked Jan 19, 2015 at 18:17 Dedalos01Dedalos01 831 gold badge1 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You should be able to do something like this:

register_activation_hook(__FILE__, 'my_plugin_activate');
add_action('admin_init', 'my_plugin_redirect');

function my_plugin_activate() {
    add_option('my_plugin_do_activation_redirect', true);
}

function my_plugin_redirect() {
    if (get_option('my_plugin_do_activation_redirect', false)) {
        delete_option('my_plugin_do_activation_redirect');
        wp_redirect(MY_PLUGIN_SETTINGS_URL);
    }
}

本文标签: activationRefresh or redirect page after activate my plugin