get_var result empty for query of custom table in plugin admin
There’s error in your query statement. Change to this $post_id = $wpdb->get_var( “SELECT post_id FROM $customtable WHERE uniquecode=”$uniquecode” AND blog_id = ‘$user_blog_id'” );
There’s error in your query statement. Change to this $post_id = $wpdb->get_var( “SELECT post_id FROM $customtable WHERE uniquecode=”$uniquecode” AND blog_id = ‘$user_blog_id'” );
You can use the following two inbuilt functions to do this. switch_to_blog get_option You can use both in the following way to make a function out of it which would give you the option. Put the below in the functions.php file function wpse_get_options( $blog_id = 1 ){ switch_to_blog( $blog_id ); $get_option = get_option( $option ); … Read more
WordPress Provides a native functions to query these kind of things very easily like WP_User_Query $args = array( ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => $meta_key1, ‘value’ => $search1, ‘compare’ => ‘LIKE’ ), array( ‘key’ => $meta_key2, ‘value’ => $search2, ‘compare’ => ‘=’ ) ) ); $user_query = new WP_User_Query( $args );
I am not sure if I understand your question right but you seem to misunderstand a bit how PHP requests are typically executed. $wpdb is not persistent, it belongs to specific page load and only exists while that page load is being performed. Unless your code always changes it – independent second (third, etc) page … Read more
Please show Your html form code. Also i think you have an error in $wpdb->insert statment. Should be: $wpdb->insert(wp_ow_odczyty, array($data));
Wpdb generates too many queries
You are using the user email as the user login. Your code, formatted for readability, looks like: $resetQuery = $wpdb -> query( $wpdb -> prepare( “UPDATE wp_users SET user_pass = %s, user_activation_key = ” WHERE user_login = %s AND user_activation_key = %s”, $hashedPwd, $useremail, $key ) ); The $useremail argument matches the user_login = %s … Read more
AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
Pass your information through prepare as in this example from the Codex: $metakey = “Harriet’s Adages”; $metavalue = “WordPress’ database interface is like Sunday Morning: Easy.”; $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) “, array( 10, $metakey, $metavalue ) ) ); Your array should have … Read more
Update tags to 10,000+ posts with wpdb?