How to pass arguments to add_action() [duplicate]

The parameter needs to be passed to the callback function in the wp_schedule_single_event function, not the add_action function. Try this: add_action(‘z_purge_products_cache’, array($this, ‘purge_products_cache’)); Then schedule the event, putting the parameter in an array: wp_schedule_single_event(time() + 20, ‘z_purge_products_cache’, array($asins_r)); Your purge_products_cache function will be called with parameter $asins_r.

how to create endpoint for downloading pdf files?

A good action to hook in would be template_redirect. There you can query for your endpoint like this: add_action(‘template_redirect’, function() { global $wp_query; // Not your endpoint and not a page/post, we do nothing. if (!isset( $wp_query->query_vars[‘download’]) || ! is_singular()) { return; } // Here goes your magic! […] // And probably a good idea … Read more

Security around save_post hook

The save_post hook is called every time someone calls the function wp_insert_post(). Plugins do that, unfortunately some themes too, and WordPress itself on several places when … someone uses post per email or XML RPC an auto-draft is created the Quick Draft feature on the dashboard is used a navigation menu item is added a … Read more

wordpress custom modules/widget areas on the page? can i make my own?

You can add additional widgetized sidebars to your theme by adding to your theme’s functions.php. If you have not already added widget support in the theme, include: if (function_exists(‘register_sidebar’)) Then add: // Footer Widgets register_sidebar(array( ‘id’ => ‘footerwidgets’, ‘name’ => ‘FooterWidgets’, ‘description’ => ‘Widgets here are shown in the footer’, ‘before_widget’ => ‘<div id=”%1$s” class=”widget … Read more

Bulk action hook for admin pages which uses WP_List_Table

You have to use “process_bulk_action” function like this: public function process_bulk_action() { //nonce validations,etc $action = $this->current_action(); switch ( $action ) { case ‘export_action’: // Do whatever you want wp_redirect( esc_url( add_query_arg() ) ); break; default: // do nothing or something else return; break; } return; } } If you need a complete example this … Read more

Hook Widget to Woo Theme in functions.php

You should use the dynamic_sidebar to spit out the widgets inside the newly created sidebar before the woo main container. add_action( ‘woo_main_before’, ‘woo_sidebar’ ); function woo_sidebar() { if (is_woocommerce()) { echo ‘<div class=”primary”>’; dynamic_sidebar( ‘filters’ ); echo ‘</div>’; } }

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)