WordPress.org

Forums

myCRED
[resolved] Removepoint when delete post (4 posts)

  1. nyan-nyan
    Member
    Posted 1 year ago #

    I used Buddypress.

    I would like to remove point when delete own post.
    Because user can repeat for delete and upload.
    So points only increase.

    any way?

    https://wordpress.org/plugins/mycred/

  2. Gabriel
    Member
    Plugin Author

    Posted 1 year ago #

    Hi!

    There is no built in limit for Points being awarded when a user posts a new content. I assume you give points for new posts under the "Points for publishing content" hook?

  3. nyan-nyan
    Member
    Posted 1 year ago #

    Hi Gabriel!

    >>"Points for publishing content"
    Yes! It is something like "Points for comments > Trashed / Unapproved Comments"

    I hope to the possibility of myCRED.

    Thanks Gabriel!

  4. Gabriel
    Member
    Plugin Author

    Posted 1 year ago #

    Your only option is to hook into the mycred_add filter which fires just before points are awarded / deducted from users allowing you to stop a process if needed. Filters simply just need to return either true (go ahead and give / take points ), false (stop what you are doing) or 'done' (in case you award points yourself due to some custom formula or something and don't want myCRED to duplicate things but indicate that points have been awarded).

    Example:

    add_filter( 'mycred_add', 'enforce_limit_for_published_content', 10, 3 );
    function enforce_limit_for_published_content( $reply, $request, $mycred ) {
    	// If another filter has already declined this, so do we
    	if ( $reply === false ) return $reply;
    
    	// Check the log how many points this user has received
    	// today for publishing content
    	$points_today = mycred_get_total_by_time( 'today', 'now', 'publishing_content', $request['user_id'] );
    
    	// In this example I assume users get 1 point per content
    	// So 1 point * 1 = 1
    	// In the user has not received points today, $points_today will return zero
    	if ( $points_today == 1 ) return false;
    
    	return true;
    }

    You can find more information on how to use the mycred_get_total_by_time function in the codex.

    Let me know if you require further assistance.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • myCRED
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.