WordPress sending data with add_action

This is untested but you should be able to hook into ‘wcvendors_approve_vendor’ action. It is also passing the $wp_user_object to you which you could get the user id from…OR $_GET is a global, so you can still access $_GET[‘user_id’] if you wanted. The ’10’ in the add_action is the priority and the ‘1’ tells it … Read more

Can add_image_size be added earlier

You can set the priority to 999 to make sure if you are going that way: add_action( ‘after_setup_theme’, ‘_my_action_add_image_sizes’, 999 ); but if you really want to make sure of that order, try making a custom action, here a small example: /** * Execute the action with do_action. */ function read_theme_options() { //all the logic … Read more

Display custom debug info inside page and not before head

Don’t print any debug info into the page directly. WordPress offers a wp-content/debug.log file which you can use. Enable debug and debug_log in your wp-config.php define( ‘WP_DEBUG’, true ); // turn debug mode on define( ‘WP_DEBUG_DISPLAY’, false ); // do not display errors define( ‘WP_DEBUG_LOG’, true ); // save errors to wp-content/debug.log define( ‘SAVEQUERIES’, true … Read more

WP search exclude last letter from string

You can use the get_search_query filter. function mySearchFunction($search_term){ $search_term = substr($search_term, 0, -1); return $search_term; } add_filter(‘get_search_query’,’mySearchFunction’); EDIT Action to filter query results: function mySearchFilterFunction($query) { if ( !is_admin() && $query->is_main_query() && $query->is_search) { $search_term = $query->get(‘s’); $query->set(‘s’, substr($search_term, 0, -1)); } } add_action( ‘pre_get_posts’, ‘mySearchFilterFunction’); get_search_query filter is not needed because it uses get_query_var( … Read more

call a function when insert and update a custom post type

This is the original answer but it is little faulty, look below for the updated You can use following approach. The my_action_updated_post_meta is executed after the post insert or update is done: // define the updated_post_meta callback function my_action_updated_post_meta( $array, $int, $int ) { global $post; // see your updated post print_r($post); // make your … Read more