Skip to content

Instantly share code, notes, and snippets.


Giang Le gianghl1983

View GitHub Profile
gianghl1983 / add-to-cart.php
Created Apr 5, 2020 — forked from webaware/add-to-cart.php
WooCommerce purchase page add-to-cart with quantity and AJAX, by customising the add-to-cart template in the WooCommerce loop. See blog post for details:
View add-to-cart.php
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
* @link
* @link
// add this file to folder "woocommerce/loop" inside theme
View caldera_forms_private_upload_directory.php
add_filter( 'caldera_forms_private_upload_directory', function( $directory, $field_id, $form_id, $transient_id ){
//IMPORTANT -- Change this to the ID of your field, or remove this conditional to affect all fields.
if( 'fld111' === $field_id ){
$uploads = wp_get_upload_dir();
$directory = $uploads[ 'basedir' ] . '/somepath';
return $directory;
gianghl1983 / form-content.html
Created Aug 6, 2019 — forked from alexmustin/form-content.html
WordPress AJAX Live Search of Post Title
View form-content.html
<!-- // The HTML (could be part of page content) // -->
<input type="text" name="keyword" id="keyword" onkeyup="fetch()"></input>
<div id="datafetch">Search results will appear here</div>
gianghl1983 / pmpromyCRED.php
Created Jun 20, 2019 — forked from strangerstudios/pmpromyCRED.php
Award MyCRED points for members who sign up for Membership Level 1.
View pmpromyCRED.php
Use this recipe in combination with MyCRED to award points to members when signing up
for Level 1 membership. This code gist could be customized to give points for another
membership level ID, award recurring points for each subscription payment, and more.
MyCRED can be downloaded/configured here:
// Register Hook for PMPro Membership Points at Signup
View Example of Ultimate Member Cover photo in Open Graph Image meta
function um_custom_init(){
remove_action('wp_head', 'um_profile_dynamic_meta_desc', 9999999);
add_action('wp_head', 'um_custom_profile_dynamic_meta_desc', 9999999);
function um_custom_profile_dynamic_meta_desc() {
global $ultimatemember;
if ( um_is_core_page('user') && um_get_requested_user() ) {
um_fetch_user( um_get_requested_user() );
View Ultimate Member - Hides current user from search query in member directory
* Hides current user from search query in member directory
add_filter('um_prepare_user_query_args', 'um_remove_current_user_from_query', 10, 2);
function um_remove_current_user_from_query( $query_args, $args ){
$query_args['exclude'] = array( get_current_user_id() );
return $query_args;
View Ultimate Member - change display name with custom name per user role
// Requires Ultimate Member v1.3.68+
// Change Displayname for Business category profiles
add_filter("um_user_display_name_filter","um_custom_businessname", 10, 2);
function um_custom_businessname( $name, $profile_id ){
um_fetch_user( $profile_id );
if( um_user('role') == 'business' ){
$name = um_user("first_name");
View Ultimate Member - Add menu items in Profile Settings menu
function um_custom_profile_edit_menu_items( $items, $profile_id ){
$items[ ] = array(
"my_custom_menu_item" => '<a href="" class="real_url">'.__('My Custom Menu Item','ultimatemember').'</a>',
return $items;
gianghl1983 / usermeta-shortcode.php
Created Mar 19, 2019 — forked from dave-mills/usermeta-shortcode.php
A WordPress custom shortcode to display a piece of user metadata from the wp_usermeta table. Relies on Ultimate Member plugin
View usermeta-shortcode.php
/* Create new shortcode for quickly displaying user metadata.
*** NOTE: This only works if you have the Ultimate Member plugin installed.
*** Use like regular wordpress shortcodes. Enter [USERMETA user_id="*id*" meta="*field_name*"] (replace *id* and *field_name* with actual values)
*** If you use it on an Ultimate Member profile page/tab, it will use the user currently being viewed.
*** On other pages, you must include the "user_id" within the shortcode.
//Add the shortcode to WordPress
add_shortcode('USER_META', 'user_meta_shortcode_handler');
//create the function referenced by the add_shortcode()
View Ultimate Member - Hide profile tabs from other user roles
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {
$user_id = um_get_requested_user();
// Show to profile owners only
if ( is_user_logged_in() && get_current_user_id() == $user_id ) {
$tabs['faves'] = array(
'name' => 'Faves',
'icon' => 'fa fa-star',
You can’t perform that action at this time.