Filter Author Bio

You can use the filters the_author_$meta and get_the_author_$meta (where $meta is in this case ‘description’): add_filter(‘the_author_decription’, ‘custom_about_member’, 10, 2); add_filter(‘get_the_author_decription’, ‘custom_about_member’, 10, 2); function custom_about_member($description, $userid) { $about = get_user_meta($userid, ‘user_about’, true); if ($about) {return $about;} return $description; } This of course relies on the place where the author bio is being displayed using the … Read more

Modify Database in Multi-Site wp_usermeta table

This Should Work? ALTER TABLE wp_usermeta ADD COLUMN old_user_id bigint(20) unsigned; INSERT INTO wp_usermeta (old_user_id) SELECT u.id FROM wp_users AS u; INSERT INTO wp_usermeta (user_id, meta_key, meta_value) SELECT u.id, ‘wp_2_capabilities’, meta_value JOIN wp_users AS u ON u.user_id = u.old_user_id; ALTER TABLE wp_users DROP COLUMN old_user_id;

How can I get the author description’s excerpt?

There is none. You have to implement your own custom function to trim any content you wish. For example, this function will trim your content based on words: function my_custom_excerpt ( $content, $limit = 20, $more=”…” ){ return $data = wp_trim_words( strip_tags( $content ), $limit, $more ); } Or this one will trim it based … Read more

create shortcode to list users with specific meta key value

Try this: function thebroker_agents() { global $current_user; $bmail = $current_user->user_email; $user_query = new WP_User_Query( array( ‘meta_key’ => ‘broker_email’, ‘meta_value’ => $bmail, ‘fields’ => ‘all’ ) ); $users = $user_query->get_results(); if (!empty($users)) { $results=”<ul>”; foreach ($users as $user){ $results=”<li>” . $user->display_name . ‘</li>’; } $results=”</ul>”; } else { $results=”No users found”; } wp_reset_postdata(); return $results; } … Read more

Adding current user’s ID to the end of PDF hyperlinks in post content

Here’s a solution that I came up with that will add the user query argument and the current user’s ID to PDF links, e.g.: http://mysite/wp-content/uploads/2018/12/My_PDF_File.pdf?user=54 This code works by inspecting the post’s content using the the_content filter, then parsing the content using DOMDocument. I’ve run into various gotchas using DOMDocument and much of this code … Read more

Filter WooCommerce Orders query with user meta data

I see 2 possible ways: 1) Using your WP_User_Query in a WC_Order_Query with the customer_id argument this way: // Users query $user_ids = (array) get_users([ ‘role’ => ‘customer’, ‘number’ => – 1, ‘fields’ => ‘ID’, ‘meta_query’ => [ ‘relation’ => ‘OR’, [ ‘key’ => ‘unsubscribed’, ‘compare’ => ‘!=’, ‘value’ => 1 ], [ ‘key’ => … Read more

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