Skip to content

Instantly share code, notes, and snippets.

{
"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 January 1, 2018 14:53
Adds support for use of shortcodes in notifications.
/**
* 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 November 29, 2020 09:14
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.
/**
* 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 December 19, 2023 20:26
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.
/**
* 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 August 14, 2020 13:05
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.
/**
* 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 July 28, 2019 10:12
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.
/**
* 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 October 16, 2017 14:07
Log the event under a unique reference based on the post type being published.
/**
* 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 February 19, 2019 12:38
Example: Reward buyer with 1 point for each product in an order, once the order is marked as completed. Requires WooCommerce 3.0+
/**
* 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 October 11, 2017 18:09
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.
add_filter( 'mycred_woo_reward_mycred_payment', '__return_true' );
@gabrielmerovingi
gabrielmerovingi / mycred-history-woo-my-account
Created October 2, 2017 12:28
myCRED history in WooCommerce "My Account" with pagination.
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
/**