How to get a users Roles and how to list all WordPress roles in PHP

This code is handy if you want to find out a users role/s. You could expand it and check if a user has a given role or similar. $user_info = get_userdata(2152); echo ‘Username: ‘ . $user_info->user_login . “\n”; echo ‘User roles: ‘ . implode(‘, ‘, $user_info->roles) . “\n”; echo ‘User ID: ‘ . $user_info->ID . … Read more

How to do Ajax in WordPress

updated 10th Jan 2018 Write a javascript function to trigger the ajax call jQuery(‘#button_or_something’).on(“click”, function() { jQuery.ajax({ url: ajax_object.ajax_url, data: { action: ‘like_or_not’, /* this is appended to add_action on server side */ id: ’99’ }, type: ‘GET’, success:function(response){ //alert(‘back from ajaxe ‘+response); /* if you want to update something based on the response text … Read more

How to speed up Woocommerce (and WordPress)

  Speed tuning in WordPress and Woocommerce This post contains details of how to supercharge your WordPress website. Here are some speed tuning tips for getting your Woocommerce store loading quickly and keep customers on your site (slow loading = loss of customers). Check file load times In firebug look at the console requests (eg … Read more

How to make a WordPress Theme, Woocommerce Compatible from scratch

beginners guide to theming Woocommerce

In this post I’ll going to explain how I took a WordPress Bootstrap Theme and made it Woocommerce Compatible. I couldn’t find many good tutorials on this so I’m writing this one, so that it might help someone else. The Process to make a theme Woocommerce Compatible I’m going to take the very nice DevDmBootstrap3 theme and make it Woocommerce … Read more

WordPress create admin reports using WP_List_Table

Wordpress create admin reports using WP_List_Table

In this post I’m going to discuss how to use WP_List_Table to create reports/tables/lists that are similar in style to the standard WordPress reports for Posts, Pages etc. To achieve this I’ll use the WP_List_Table core WordPress class, this contains the functionality to create said tables/reports. This example will look at the links table and … Read more