Shortcode [aff_permanent_count]

Antonio created a very useful shortcode so the affiliates can keep track of how many customers are linked to their affiliate account (using affiliates permanent plugin).

The code is here: http://eggemplo.com/blog/aff_permanent_count-shortcode/

I’ve added this in function.php and while it works and shows the variable I also get an warning / error at the top of the screen when the code is inserted:

Warning: Missing argument 2 for wpdb::prepare(), called in /home/modem/domains/domainname.nl/public_html/wp-content/themes/bazar/functions.php on line 29 and defined in /home/modem/domains/domainname.nl/public_html/wp-includes/wp-db.php on line 1152

Did I do something wrong or is there a small error in the script?


Comments

3 responses to “Shortcode [aff_permanent_count]”

  1. That did the trick, thanks a lot!

    1. Updated, thank you both !!

  2. Hi Nasier,

    The code is using the prepare() method without passing any arguments to it. This line:

    $user_meta_query = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key='$meta_key' AND meta_value='$meta_value'" ) );

    should read:

    $user_meta_query = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key=%s AND meta_value=%s", $meta_key, $meta_value ) );

    Cheers

Share