WP User Query with Custom Fields and Search Results

Not sure if you ever found the answer, but just in case, I just did 🙂 There’s a hook I (finally!) found that lets you do this and works in a similar way to posts_where. The hook is pre_user_query. Here’s an example on the Codex: https://developer.wordpress.org/reference/hooks/pre_user_query/#user-contributed-notes With the above, your function could now look like … Read more

Get author Meta for particular user inside the loop

The function get_the_author_meta(‘ID’) will return the ID of the author for the current post. That means this line should work. get_avatar( get_the_author_meta( ‘ID’ ), 120); This will not work get_avatar( get_the_author_meta( ‘4’ ), 120); Because you are trying to get a property named ‘4’ inside the user object and that property doesn’t exist. If you … Read more

Read array in php?

Fastest way would be something like this: $fruit_id = get_user_meta($user_id, ‘fruit’, true); //returns 1 $display_fruit = some_fruits($fruit_id); //will return ‘Apple’

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