Skip to content

Instantly share code, notes, and snippets.

Gabriel Merovingi gabrielmerovingi

View GitHub Profile
View uamplified-api-product-object
{
"product_id": 2,
"title": "Product Title",
"url": "https://company.uamplified.io/product-slug/",
"slug": "product-slug",
"logo": "",
"version": "1.0",
"visibility": "public",
"created_date": 1533565994,
"total_members": 3,
@gabrielmerovingi
gabrielmerovingi / mycred-notifications-note-filter-example
Created Jan 1, 2018
Adds support for use of shortcodes in notifications.
View mycred-notifications-note-filter-example
/**
* Render Shortcodes in Notifications
* @version 1.0
*/
function mycred_pro_render_shortcodes_in_notice( $notice ) {
return do_shortcode( $notice );
}
add_filter( 'mycred_notifications_note', 'mycred_pro_render_shortcodes_in_notice' );
@gabrielmerovingi
gabrielmerovingi / mycred-wpulike-per-type
Last active Oct 24, 2017
When getting points for liking a content, change the reference to identify the post type so we can create badges for each post type that gets liked instead of just one for all likes.
View mycred-wpulike-per-type
/**
* Adjust WP ULike Reference
* When getting points for liking a content, change the reference
* to identify the post type so we can create badges for each post type
* that gets liked instead of just one for all likes.
* @version 1.0
*/
add_filter( 'mycred_run_this', 'mycred_wpulike_per_cpt', 10, 3 );
function mycred_wpulike_per_cpt( $run_this, $mycred ) {
@gabrielmerovingi
gabrielmerovingi / mycred-view-content-category-hook
Last active Oct 24, 2017
This custom hook allows you to reward users viewing content based on the category the post belongs to. Goes into your child theme's functions.php file or custom plugin.
View mycred-view-content-category-hook
/**
* Register Custom Hook
* @since 1.0
* @version 1.0
*/
add_filter( 'mycred_setup_hooks', 'mycred_pro_register_view_content_category_hook' );
function mycred_pro_register_view_content_category_hook( $installed ) {
$installed['view_category_content'] = array(
'title' => __( '%plural% for Viewing Content (Categories)', 'mycred' ),
@gabrielmerovingi
gabrielmerovingi / mycred-publish-content-cat-hook
Last active Oct 26, 2017
This custom hook allows you to reward posts being published based on the category they are assigned. The hook will reward points when a post is published, so if a category is added after publishing, it will not payout. Goes into your child theme's functions.php file or custom plugin.
View mycred-publish-content-cat-hook
/**
* Register Custom Hook
* @since 1.0
* @version 1.0
*/
add_filter( 'mycred_setup_hooks', 'mycred_pro_register_publish_content_category_hook' );
function mycred_pro_register_publish_content_category_hook( $installed ) {
$installed['publish_category_content'] = array(
'title' => __( '%plural% for Publishing Content (Categories)', 'mycred' ),
@gabrielmerovingi
gabrielmerovingi / points-for-publishing-content-hook-example
Last active Oct 19, 2017
Custom hook that allows you to set a specific amount of points to reward users when they publish posts in a pre-defined sets of categories.
View points-for-publishing-content-hook-example
/**
* Register Custom Hook
* @since 1.0
* @version 1.0
*/
add_filter( 'mycred_setup_hooks', 'mycred_pro_register_publish_content_category_hook' );
function mycred_pro_register_publish_content_category_hook( $installed ) {
$installed['publish_category_content'] = array(
'title' => __( '%plural% for Publishing Content (Categories)', 'mycred' ),
@gabrielmerovingi
gabrielmerovingi / mycred-publish-hook-ref-filter-example1
Created Oct 16, 2017
Log the event under a unique reference based on the post type being published.
View mycred-publish-hook-ref-filter-example1
/**
* Adjust Publish Reference
* Log the event under a unique reference based on the post type being published.
* @version 1.0
*/
function mycred_pro_publish_ref_by_type( $reference, $post ) {
return 'publish_' . $post->post_type;
}
@gabrielmerovingi
gabrielmerovingi / reward-completed-woo-orders
Last active Feb 19, 2019
Example: Reward buyer with 1 point for each product in an order, once the order is marked as completed. Requires WooCommerce 3.0+
View reward-completed-woo-orders
/**
* Reward Completed Orders
* Will give a user 1 point for each product in an order.
* @version 1.0.1
*/
function mycred_pro_reward_completed_orders( $order_id ) {
if ( ! function_exists( 'mycred' ) ) return;
$order = wc_get_order( $order_id );
@gabrielmerovingi
gabrielmerovingi / reward-mycred-payment
Created Oct 11, 2017
By default, myCRED will not reward points if an order in WooCommerce was paid with points. This is how you override this and force myCRED to payout anyways.
View reward-mycred-payment
add_filter( 'mycred_woo_reward_mycred_payment', '__return_true' );
@gabrielmerovingi
gabrielmerovingi / mycred-history-woo-my-account
Created Oct 2, 2017
myCRED history in WooCommerce "My Account" with pagination.
View mycred-history-woo-my-account
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
/**
You can’t perform that action at this time.