How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?

To add to @EAMann’s answer, you need to wrap your wp_get_current_user() call (or any call that tries to access a function defined within pluggable.php) within the ‘plugins_loaded’ action. So, if you’re putting this inside your functions.php file, do it like this: add_action( ‘plugins_loaded’, ‘get_user_info’ ); function get_user_info(){ $current_user = wp_get_current_user(); if ( !($current_user instanceof WP_User) … Read more

Adding a second email address to a completed order in WooCommerce [closed]

There’s actually a filter that you can use, see abstract-wc-email.php, line 214: return apply_filters( ‘woocommerce_email_recipient_’ . $this->id, $this->recipient, $this->object ); you can put the following in your functions.php: add_filter( ‘woocommerce_email_recipient_customer_completed_order’, ‘your_email_recipient_filter_function’, 10, 2); function your_email_recipient_filter_function($recipient, $object) { $recipient = $recipient . ‘, [email protected]’; return $recipient; } the only drawback is that the recipient will see … Read more

How to override parent functions in child themes?

You should run the code after theme setup. function osu_twentyten_continue_reading_link() { return ‘ <a href=”‘. get_permalink() . ‘”>’ . __( ‘Read on <span class=”meta-nav”>&rarr;</span>’, ‘twentyten-child’ ) . ‘</a>’; } function osu_twentyten_auto_excerpt_more( $more ) { return ‘ &hellip;’ . osu_twentyten_continue_reading_link(); } function my_child_theme_setup() { remove_filter( ‘excerpt_more’, ‘twentyten_auto_excerpt_more’ ); add_filter( ‘excerpt_more’, ‘osu_twentyten_auto_excerpt_more’ ); } add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ … Read more

Best collection of code for your 'functions.php' file [closed]

Enable Hidden Administration Feature displaying All Site Settings Tested on: WordPress 3.1 RC3 This little piece of code does something pretty cool. It will add an additional option to your settings menu with a link to “all settings” which will show you a complete list of all the settings you have within your database related … Read more