Using WordPress meta field values for dynamic Gravity Form emails

Ever use Gravity Forms and want to easily add a form that takes an email value from the post? For example maybe you have store profile posts and each post has a contact form in the sidebar, but you want the email sent to each individual  person/store/whatever. Well there is a really simple way to do that.

function your_custom_notification_signature( $notification, $form) {

   //This example is using a form with the id of 1
    if($form["id"] == 1){
        global $post;

        //the example email is stored in a post meta field called "_cmb_email"
        $store_email = get_post_meta( $post->ID , '_cmb_email', true );
        $notification['to'] = $store_email;

       return $notification;

add_filter('gform_notification', 'your_custom_notification_signature', 10, 3);

You can change a lot more than that as well, have a look at:


How to remove error notices using WordPress’s WP_DEBUG

A neat trick I learned today to remove or adjust PHP error reporting when using `WP_DEBUG`. It’s often the case that a theme or plugin author has either not written code with debug on or perhaps supporting an older version of PHP so error notices can hinder the output visually or fill up your log file. A theme I was working on that caused me to find a solution was adding 8k lines of debug output to the log file every couple hours!

In your `wp-content` folder create a new folder called `mu-plugins` and in that folder create a php file with the error level you want, for example:

//Turns off notices
error_reporting(E_ALL ^ E_NOTICE);

If you are using PHP 5.5 +, you will get deprecated noticed for WordPress’s mysql_* functions, you can turn them off using:

error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);

Or for something really robust, which happens to be the case a lot.



I you develop themes/plugins please turn on debugging and support at the very least PHP 5.4!

Enabling Zend OPcache on Ubuntu and Apache

opcodeZend OPcache is the new open source opcode PHP cache that is now bundled with PHP 5.5. I had just upgraded one of my servers running Ubuntu 12.04 to use Apache 2.4.6 and PHP 5.5.4.

So how does one install it? I initially thought I had to just edit the php.ini file since there are a bunch of new settings for the opcache. I set mine similar to the recommended default and did not enable `cli` caching.


Restarting Apache however and I saw that it was still disabled , even though I had also set


Continue reading

WordPress exploits – A review of what’s going on

As you may or may not know I setup as a hobby a few years ago to track exploits for plugins hosted on The main reason I created the site was twofold, to alleviate some of the finger-pointing directed at WordPress core, and to educate users and plugin authors since most vulnerabilities are easy to correct using proper WordPress or PHP/JS coding practises.

Continue reading

How to center align auto WordPress embeds

I came across this problem the other day when using WordPress auto embed feature. When you add an embed URL, for example “ ..”   it will automatically be aligned to the left (this depends on the theme). This can look odd depending on your layout, there is a trick to make it centered in the post by doing the following in the text editor:

<div style="text-align: center;">  
... embed url ...  

It’s important that the div and the embed URL are all on separate lines.

Beware: Also there is a major drawback in that if you update the post again it will auto format the markup and remove the line spaces and the auto embed will not work.