Add-action in function

You can simply remove those menu items in your check_username method. add_action(‘admin_init’, ‘check_username’); function check_username() { $user = wp_get_current_user(); if( $user && isset($user->user_email) && ‘[email protected]’ == $user->user_email ) { remove_menu_page(‘tools.php’); remove_menu_page(‘themes.php’); remove_menu_page(‘options-general.php’); remove_menu_page(‘plugins.php’); } } Your code doesn’t work, because the admin_init action is invoked after admin_menu. Please see the Action reference page in WordPress … Read more

How to enable/disable a hook with theme options

Actually all I had to do is, run theme options inside the function, like this: function mytheme_under_construction(){ global $mytheme; if(!empty($mytheme[‘offline_id’])){ // if user is logged in, don’t show the construction page if ( is_user_logged_in() ) { return; } $protocol = $_SERVER[“SERVER_PROTOCOL”]; if ( ‘HTTP/1.1’ != $protocol && ‘HTTP/1.0’ != $protocol ) $protocol=”HTTP/1.0″; // 503 is … Read more

do_action in header, add action later?

You must register callbacks before they are called (add_action() and add_filter() are registration functions, they remember what to do when). Try the following in your functions.php or in your plugin: add_action( ‘topofthetop’, ‘load_FB_JS_SDK’ ); function load_FB_JS_SDK() { if ( is_singular() && have_comments() ) someclass::FB_JS_SDK(); }

save_post action not firing when save

You have some errors in your code. For example, you unset a not defined variable. Some lines bellow you try to use again a not defined variable….maybe this is what is causing the problems. Can you try this? (Edited, I think is better get_posts than new WP_Query in this case) function wpse_update_postmeta($post_id) { if (defined(‘DOING_AUTOSAVE’) … Read more