How do I find users by password?

The user password (stored as an MD5 hash) can be retrieved like so: $users = get_users(); foreach ( $users as $user ) { $password = $user->user_pass; } Assuming you have some known value for passkey, you can hash it and compare it to each user’s password: $passkey = ‘somestring’; $hashed_passkey = md5( $passkey ); $users … Read more

Custom WordPress Excerpt within terms

I’ve used code like this, based (extremely) loosely on the plugin relevanssi: (in “functions.php”) // Roughly based on the relevanssi_do_excerpt() (https://wordpress.org/plugins/relevanssi/, GPLv2 or later), seriously simplified. function mytheme_search_context( $haystack, $needles, $len = 30 ) { $ret=””; $haystack = strip_tags(mytheme_strip_invisibles($haystack)); $haystack = trim( preg_replace( array( “/\n\r|\r\n|\n|\r/”, ‘/\s\s+/’, ‘/&.{1,30}?;/’ ), ‘ ‘, $haystack ) ); $words = … Read more

How to make custom WordPress page deliver search results

Maybe it´s easier to output some content from a different page/post in your search template which got a fixed slug. I for example use this: $page = get_posts(array(‘name’ => ‘welcome’)); if ($page) { echo ‘<h1>’.$page[0]->post_title.'</h1>’; echo ‘<p>’.$page[0]->post_content.'</p>’; } This fetches the post with the slug “welcome” and displays its content. As I don´t use a … Read more

Query comments with non-empty ‘author_url’ value on Admin Comments Screen

We can set the author_url argument of WP_Comment_Query as null (empty string will not work) to search for comments that don’t have an author url. Currently (ver 4.8.1) the has_author_url isn’t supported. Using a sub-query to exclude those comments, with no author_url, using comment__not_in, should work, but wouldn’t probably scale well. Setting fields as ids … Read more

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