Fetching User Information from Rapportive via PHP

Rapportive in Gmail

Rapportive in Gmail

I love Rapportive. It’s a nifty way to know about a user who sent you an email to your Gmail account. You can know about the person who sent the email and treat the person that way. It collects its data from various sources including social networks. But, you can only use that in your Gmail as a browser add-on.

As a developer, that’s kinda sad. Wouldn’t it be nice to be able to use those information in your custom application? Well, there is a hack that I found and turned it into a PHP class for easier usage and it’s kinda cool :D

So I wrote this nifty PHP class and it makes fetching the data a breeze.

Using

require dirname( __FILE__ ) . '/rapportive.php';

$rap = new WeDevs_Rapportive( 'tareq@wedevs.com' );
var_dump( $rap->get_data() );

Output

Data from Rapportive

GitHub

Dokan – A multi-vendor e-commerce app theme is coming soon…

“Dokan” – an upcoming WordPress app theme for building multi-seller e-commerce store, powered by WooCommerce. Me and my team are working on this for couple of months and it’s going to be released at end of this month or in first half of February.

It’s using WooCommerce as it’s backend engine and will be based on upcoming WooCommerce 2.1. So if you want to build a site having multiple vendors, you can easily do that.

Hopefully it’ll be released at end of this month or in first half of February.

It has a nice user friendly dashboard in front-end. So if you want to build a site for your client, may be it’ll be a good start if your client isn’t familier with WordPress dashboard :D

Screenshots

Continue reading

Wildcard search using WP_User_Query()

You can use WP_User_Query() class to fetch users by various arguments. With it’s search parameter, you can search users by these columns 'ID', 'login', 'user_nicename', 'user_email', 'user_url'. Although you’ve to specify which columns you want perform the search.

$user_query = new WP_User_Query( array( 'search' => 'Tareq' ) );

When searching users with the search parameter, by default WordPress searches for direct match. It doesn’t search with any wildcard even if you pass like this: array( 'search' => '%Tareq%' ), instead it’ll escape the percentage sign.

But there is a hidden gem by which you can search with wildcards. Just put * at the beginning and/or in the end of your string. WordPress will replace * with % sign and you can search with wildcard. There is no documentation about this!

Example:

$user_query = new WP_User_Query( array( 'search' => '*Tareq' ) ); // '%Tareq'
$user_query = new WP_User_Query( array( 'search' => 'Tareq*' ) ); // 'Tareq%'
$user_query = new WP_User_Query( array( 'search' => '*Tareq*' ) ); // '%Tareq%

Pretty neat!

WooCommerce sold out badge on products listing

Someone asked me in my facebook page that how could he add “Sold Out” badge in WooCommerce product. Well, here’s how:

WooCommerce Sold Out badge

add_action( 'woocommerce_before_shop_loop_item_title', function() {
    global $product;

    if ( !$product->is_in_stock() ) {
        echo '<span class="onsale soldout">Sold Out</span>';
    }
});

Paste this snippet in your themes functions.php and voila! Change the color as you wish using CSS, don’t ask me how ;)

Note: This code snippet requires your PHP version 5.3 or above.