Intercept request to /wp-content/uploads/random.file

I just ran a test where I uploaded an image to media library, then renamed my root index.php file to break WordPress, but the image I uploaded was still available by accessing it directly with its wp-content/uploads/… URL. There are no .htaccess files in wp-content or uploads either, which means that, barring any plugins that … Read more

How to remove action from plugin?

You want: remove_action(‘um_post_registration_approved_hook’, ‘um_post_registration_approved_hook’, 10, 2); … to run after the original add_action, but before the action triggers the function um_post_registration_approved_hook The easiest way to do this, but I haven’t tested it, might be to just give your removal an earlier priority on the same hook: add_action( ‘um_post_registration_approved_hook’, ‘remove_my_action’, 9 ); function remove_my_action(){ remove_action(‘um_post_registration_approved_hook’, ‘um_post_registration_approved_hook’, … Read more

How to add a checkbox inside the “Publish post” widget?

Hook into post_submitbox_misc_actions and print the checkbox: add_action( ‘post_submitbox_misc_actions’, function() { ?> <div class=”misc-pub-section”> <label><input type=”checkbox”> click me</label> </div> <?php }); Wrap the code in a <div class=”misc-pub-section”>, otherwise the spacing looks a little bit weird. Examples: language selector, noindex checkbox, public preview checkbox.

Hook before inserting user into database [duplicate]

If you examine the wp_insert_user() function, you can see there are a myriad of filters and actions that are called throughout the process. The first is a filter called pre_user_login on the username. Line 1304 of wp-includes/user.php: $user_login = apply_filters(‘pre_user_login’, $user_login); You could hook onto that and throw your own custom error message. Edit: The … Read more

Call to undefined add_action() in theme’s functions.php

register an ajax action for submitting email: Note handle_form is the name of your action in this example add_action(‘wp_ajax_handle_form’,’handle_form_submit_111605′ ); also add this in order to make it work for non logged in users add_action(‘wp_ajax_nopriv_handle_form’,’handle_form_submit_111605′ ); do validation and mail sending job in the callback function handle_form_submit_111605 In functions.php function handle_form_submit_111605() { } User simply … Read more

Use external link in the add sub menu

Last argument of function add_submenu_page is the name of the function to call when display the content of the page. As described here: http://codex.wordpress.org/Function_Reference/add_submenu_page The right use is: add_submenu_page( ‘antify’, ‘Plugins’, ‘Plugins’, ‘manage_options’, ‘plugins’, ‘my_function’ ); function my_function(){ echo ‘hello’; } If you want a separate file you can do this add_submenu_page( ‘antify’, ‘Plugins’, ‘Plugins’, … Read more

How to Remove a Filter from the Admin List Table?

I can see that it’s implemented inside the class WC_Admin_List_Table_Orders which extends WC_Admin_List_Table. Yes, that’s correct. And the orders list table is setup via WC_Admin_Post_Types::setup_screen() where the method is called via these hooks: (see WC_Admin_Post_Types::__construct()) // Load correct list table classes for current screen. add_action( ‘current_screen’, array( $this, ‘setup_screen’ ) ); add_action( ‘check_ajax_referer’, array( $this, … Read more