Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author WPExperts.io

    (@wpexpertsio)

    Hi @a5345534,
    Thanks for using myCred please add this code in your functions.php file.

    add_action('mycred_init', 'promote_user_role');
    
    function promote_user_role() {
        $user_id  = get_current_user_id();
        $ref_sums = mycred_get_users_reference_sum( $user_id );
    // Check if user has gained points for published content
    if ( ! empty( $ref_sums ) && array_key_exists( 'publishing_content', $ref_sums ) ) {
    
        // If they have, check if it's over 1000 points and that they are not yet "Authors"
        if ( $ref_sums['publishing_content'] >= 1000 && ! user_can( $user_id, 'publish_posts' ) )
            wp_update_user( array(
                'ID'   => $user_id,
                'role' => 'author'
            ) );
    
    }
    }
    
    Thread Starter a5345534

    (@a5345534)

    thanks for your help

    i allready add this code in this functions.php file.

    bactopur.com/public_html/wp-content/themes/oceanwp/functions.php

    Do I still need to do anything?

    Plugin Author WPExperts.io

    (@wpexpertsio)

    Hi @a5345534,
    Please make sure to enable this hook after adding the code as shared in the screenshot below.

    https://drive.google.com/file/u/1/d/1UGHabwZgxKSeWEESrO0jEZnEwd_MqCj_/view?usp=sharing

    Thread Starter a5345534

    (@a5345534)

    WOW,i am sure it worked.

    But I do n’t want to limit it to publishing_content

    I want the function to refer to total balance

    How should I modify it?

    Thread Starter a5345534

    (@a5345534)

    it’s workes!!

    thanks you very much!!

    add_action(‘mycred_init’, ‘promote_user_role’);

    function promote_user_role() {
    $user_id = get_current_user_id();
    $ref_sums = mycred_get_users_balance( $user_id );

    // check if balance over 3000 points and that they are not yet “gold_member”

    if ( $ref_sums >= 3000 ){
    wp_update_user( array(
    ‘ID’ => $user_id,
    ‘role’ => ‘gold_member’
    ) );

    }
    }

    • This reply was modified 4 years, 10 months ago by a5345534.
    Plugin Author WPExperts.io

    (@wpexpertsio)

    Hi,
    It’s great to hear that your issue is resolved we would appreciate a kind and honest review.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how to use this upgrade role code’ is closed to new replies.