Register activation hook

Register activation hook

The register_activation_hook function registers a plugin function to be run when the plugin is activated.
This is useful when you try do something add custom table database, option etc.

Example:

function myplugin_activate() {

    // Activation code here...
   // Add setting option onactivation
         if(!get_option( 'rvps_settings' )){

        add_option( 'rvps_settings', array(
            'rvps_label' 			=> 'Recently viewed products'
            
        }
}
register_activation_hook( __FILE__, 'myplugin_activate' );

 

Facebook Comments
No Comments

Sorry, the comment form is closed at this time.