• Resolved betterlikethis2020

    (@betterlikethis2020)


    my site have paid membership, is it possible to allow user to have an option to use the point to upgrade to a different user role?

    What plugin mycred is compatible for this feature?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @betterlikethis2020

    Thanks for contacting us.

    I hope you are doing well, Please add the following code snippet in your theme’s functions.php file.

    Promote Based on Balance.

    • Changes a users role based on their myCRED balance.
    • @version 1.0.4
    add_filter( 'mycred_add_finished', 'check_for_role_change', 99, 3 );
    function check_for_role_change( $reply, $request, $mycred ) {
      // Make sure that if any other filter has declined this we also decline
      if ( $reply === false ) return $reply;   // Exclude admins
      if ( user_can( $request['user_id'], 'manage_options' ) ) return $reply;   extract( $request );   // Minimum balance requirement for each role
      $thresholds = array(
      'contributor'   => 100,
      'author'        => 1000,
      'editor'        => 10000,
      'administrator' => 100000
      );
      // Get users current balance
      $current_balance = $mycred->get_users_balance( $user_id, $type );
      $current_balance = $current_balance + $amount;   // Check if the users current balance awards a new role
      $new_role = false;
      foreach ( $thresholds as $role => $min ) {
      if ( $current_balance > $min )
          $new_role = $role;
      }   // Change users role if we have one
      if ( $new_role !== false )
      wp_update_user( array(
          'ID'   => $user_id,
          'role' => $new_role
      ) );
      return $reply;
    }

    Let me know if you still have any issue.

    Thanks & Regards
    WP Experts Support Team

    Hi there,

    Due to a lack of activity, we are going to mark this ticket as resolved. If you have any other issues, please feel free to open a new ticket.

    Have a great day!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can member use point to pay for a different user role?’ is closed to new replies.