appthemes_init

This hook runs after all theme files have been included, but before anything else is loaded into the theme.

Use the appthemes_init action hook when you want to execute something before the page begins to be rendered.

Usage

This hook provides no parameters. You use this hook by having your function echo output to the browser, or by having it perform background tasks. Your functions shouldn’t return, and shouldn’t take any parameters.

add_action( 'appthemes_init', 'your_function' );

Example: Banned Users

If you do not want certain users to access your site, you can create a hook to check for their IP address, and then use the wp_die() command to stop the page from loading.

function check_banned_user(){
     $banned_user_ip = '192.168.1.1';
 
     // If the user's IP matches, end the request and send a message
     if( $_SERVER['REMOTE_ADDR'] == $banner_user_ip )
        wp_die( __( 'You have been banned.', 'appthemes' ) );
}
 
add_action_hook("appthemes_init", "check_banned_user");

Example: Registering Other Hooks

You can also create a hook to optionally register other hooks. For instance, if you only want to register a hook inside the admin section, you could use the is_admin() function to decide whether or not to register the hook.

function register_my_admin_hook(){
    if( is_admin() ){
        register_hook( 'wp_head' , 'my_function' );
}
 
add_action_hook( 'appthemes_init', 'register_my_admin_hook' );

Changelog

  • since 1.1

Source File

appthemes_init() is located in includes/theme-functions.php.

Your rating: none
Rating: 0 - 0 votes

Popular Add-ons

Selected ads For Classipress

Display Selected ads widget for Classipress


(1)
$12

Smooth Approve

Enhances the default ClassiPress ad moderation feature.


(8)
$19

Downvote Not

Block downvoting genuine and verified coupons on Clipper powered website


(3)
$15