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 badges1 Answer
Reset to default 0You 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
版权声明:本文标题:activation - Refresh or redirect page after activate my plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736290658a1928560.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论