Wordpress 3

The basic format for the add_filter function is: add_filter(‘pre_option_’.$option, ‘override_function_name’); Where $option is the name of the Option as found in the wp_options table of the database. This example uses a filter to update the admin_email set in Options to that of the current user, so ‘admin_email’ becomes ‘pre_option_admin_email’. add_filter(‘pre_option_admin_email’, ‘override_option_admin_email’); function override_option_admin_email() { global…

This function returns the user role by name rather than by capabilities which is useful for determining whether the current user is a Wholesale customer for instance. It can also return the name of the user role given the user ID as a parameter. /** * Checks if a particular user has a role. *…

This is useful for non WordPress pages on a WordPress installation. Add this to the top of the page: <?php include(‘wp-load.php’); if(!current_user_can(‘editor’)) { wp_redirect( wp_login_url() ); } ?> To restrict access to admin only change “editor” to “administrator”. wp-load.php loads the WordPress functions so yo can use the current_user_can() function

To change how WordPress crops an image to create the thumbnail: Select the image in Media Library Click the “Edit Image” button under the large image If you only want the change to apply to the thumbnail select “Apply changes to thumbnail” in “Thumbnail Settings” Click and drag the cursor over the image to highlight…

For example to run WordPress on a URL such as:http://www.babelscribe.com/~mysite/ Change siteurl and blogname in the options table to the above url. Change default htaccess redirects to: RewriteEngine On RewriteBase /~mysite/ RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /~mysite/index.php [L] This is useful if you need to access an account…

In additional settings field of Contact From 7 admin: on_sent_ok: “_gaq.push([‘_trackEvent’, ‘Contact Form’, ‘Submit’]);” Google Analytics will track it as an event with Contact Form as the Category, and Submit as the Action. In Google Analytics go to Content > Events > Overview

Updating URLs in the database can cause problems if you include those in serialized arrays. These queries leave serialized arrays untouched: UPDATE wp_options SET option_value = REPLACE(option_value, ‘http://devdomain.local‘, ‘http://livedomain.com‘) WHERE option_value NOT LIKE ‘%{%’; UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ‘http://devdomain.local‘, ‘http://livedomain.com‘) WHERE meta_value NOT LIKE ‘%{%’; UPDATE wp_posts SET post_content = REPLACE(post_content, ‘http://devdomain.local‘, ‘http://livedomain.com‘)…