Exclude subscriber users from user list

I want to exclude Subscribers from a user list. My code is: $users = $wpdb->get_results( “SELECT display_name FROM $wpdb->users ORDER BY display_name ASC” ); How can I change that so subscribers are excluded from the list? I also looked at the get_users function in codex but it did not have an exclude by role parameter.  … Read more

Converting mysql to $wpdb

I’m trying to convert this to using a $wpdb class. It will return all the enums possible and i have to use this $wpdb due to mysql_query giving me weird error (no database selected) Code is following function getEnumValues($table, $field) { $enum_array = array(); $query = ‘SHOW COLUMNS FROM `’ . $table . ‘` LIKE … Read more

How to save html and text in the database?

I have two fields. The first is for plain text (but with special characters) and the second for html content (wp_editor is used). Both are later needed for phpmailer. <textarea style=”width:100%;height:200px;” name=”doi-altbody”><?php echo $epn_doi_altbody; ?></textarea> wp_editor( $epn_doi_body, ‘doi-body’, array( ‘editor_height’ => ‘300px’ ) ); 1) How do i correctly secure them after submitting the form … Read more

How to iterate through database until it find a match

How can I loop through my WordPress query, and check each posts if one meta_value of meta_key user_ip_reservering match the $ipadres Code $args = array( ‘post_type’ => ‘reserveringen’, ); $reservation_query = new WP_Query( $args ); if ( $reservation_query->have_posts() ) : ?> <ul> <!– the loop –> <?php while ( $reservation_query->have_posts() ) : $reservation_query->the_post(); ?> <li><?php … Read more

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

I have this code: $query = “SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id WHERE ((post_type=”projects”) OR (post_type=”post_cost_codes”));”; $results = $wpdb->query($query); // Takes 1.5 seconds I also tried this: $query = “SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id INNER JOIN $wpdb->term_relationships … Read more

“The plugin generated 2694 characters of unexpected output…” on Plugin activation, CREATE TABLE sql command not working

Trying to create a table in the wpdb when activating the plugin I am working on and getting the error “The plugin generated 2694 characters of unexpected output…” I’ve been over the code and done heaps of googling to try and figure out what I’ve done wrong with no success. Can someone take a look … Read more