Shortcode [aff_permanent_count]

Posted in

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?

3 Responses to Shortcode [aff_permanent_count]

  1. Nasier February 2, 2015 at 7:29 pm #

    That did the trick, thanks a lot!

    • antonio February 3, 2015 at 8:29 am #

      Updated, thank you both !!

  2. kento February 2, 2015 at 6:13 pm #

    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

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share