How to validate inputs with filter in register_setting callback

First of all I would recommend you to rename your function to wpPartSanitize_settings, because this function doesn’t validate anything. As it doesn’t validate anything, then you aren’t able to “inform” administrator that one input is invalid. Nevertheless, to create your hook for wpPartValidate_settings filter, just do it like this: add_filter( ‘wpPartValidate_settings’, ‘wpse8170_sanitize_settings’, 10, 2 ); … Read more

Listing wordpress users with a search function

This worked for me. $user_query = new WP_User_Query( array( ‘search’ => ‘*example.net*’, ‘search_columns’ => array(‘user_url’) )); $authors = $user_query->get_results(); The wild card to be used in the search string is ‘*’ and not ‘%’. Also you have to include the ‘search_columns’ parameter with the following possible values search_columns = array( ‘user_nicename’, ‘user_login’, ‘user_email’, ‘user_url’ ) … Read more

Adding filter to the title without affecting the menu title

Since you’re generating things on the fly, we can use a global flag to let us know when we want the title applied. add_filter(‘the_content’, function($content){ if(is_page(‘compare’)){ global $asin_doing_template; // mark that we’re doing a template $asin_doing_template = true; $asin = esc_attr($_GET[‘asin’]); $data = get_data($asin); $smarty->assign(‘item_data’, $data); $content = $smarty->fetch(‘file.tpl’); // set it back to false … Read more