WP_user_query throws a 404 error

pre_user_query is called after the query variable object is created, but before the actual query is run. Your code is creating a new query within the action when you should actually modify the existing query’s arguments using the $query->set() method. For example: function my_pre_user_search($user_query) { $meta_query = array(array( ‘key’ => ‘member_id’, ‘value’ => ‘2349’ )); … Read more

How to use an associative array in post__in with WP_Query?

Take a look at PHP’s array_values function. Alternatively, you could typecast. Note that if the array is in serialized form as you have put it above, you will have to unserialize it first, in either case. $numerical_array = array_values( unserialize( ‘a:1:{s:8:”post-134″;s:3:”134″;s:8:”post-136″;s:3:”136″;}’ ) ); or $numerical_array = (array) unserialize( ‘a:1:{s:8:”post-134″;s:3:”134″;s:8:”post-136″;s:3:”136″;}’ );

How to save multiple options from a dropdown in user profile

You will need an opening select tag that tells PHP it is an array. Something along the lines of the following should get you on your way… <?php // Display Fields add_action( ‘show_user_profile’, ‘add_multiple_choice_dropdown ‘ ); add_action( ‘edit_user_profile’, ‘add_multiple_choice_dropdown ‘ ); function add_multiple_choice_dropdown ( $user ) { $current_selections = get_user_meta( $user->ID, ‘multi_dropdown’, true ); ?> … Read more

Get an array of meta_values for a user meta_key

You just need to add a DISTINCT to your SQL query, something like: $cities = $wpdb->get_col(“SELECT DISTINCT(meta_value) FROM $wpdb->usermeta WHERE meta_key = ‘my_cities_meta_key'” ); Alternatively, if you want to do it with php for some reason (if you want to know that a city is listed twice before displaying only unique entries) $cities = $wpdb->get_col(“SELECT … Read more

How to use Buddypress xProfile field as WordPress Bio

To just answer this question.. Hope it’s okay to pull this back up ^^ <div class=”profile-bio”> <!– Profile user info bio text –> <?php if ( $string = xprofile_get_field_data( ‘About’, get_the_author_meta(‘ID’) ) ) { echo ‘<div class=”author-about”>’; echo $string; echo ‘</div>’; } ?><!– EOF Profile user info bio text –> </div> I’m also using this, … Read more

Display user meta by different user role

In your author.php file, get the user metadata via get_user_meta(), then do an if statement of $user->roles == ‘rivenditore’, display the meta data as you desire, and then do an elseif $user->roles == ‘installatori’ statement with what you wish to display for users on other roles. EDIT: Code example as requested: // get author data … Read more

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