Search
 
SCRIPT & CODE EXAMPLE
 

PHP

woocommerce subscriptions custom user rolde

add_action( 'woocommerce_subscription_status_expired', 'change_user_role_on_subscription_expired', 10, 1 );
function change_user_role_on_subscription_expired( $subscription ) {
    // Get WP_User Object from subscription
    $user = new WP_User($subscription->get_user_id());

    if ( in_array('agencia_pro', $user->roles) ) {
        $user->remove_role( 'agencia_pro' );
        $user->add_role( 'agencia' );
    }
    elseif ( in_array('agencia_pro_plus', $user->roles) ) {
        $user->remove_role( 'agencia_pro_plus' );
        $user->add_role( 'agencia' );
    }
    elseif ( in_array('talento_pro', $user->roles) ) {
        $user->remove_role( 'talento_pro' );
        $user->add_role( 'talento' );
    }
    elseif ( in_array('talento_pro_plus', $user->roles) ) {
        $user->remove_role( 'talento_pro_plus' );
        $user->add_role( 'talento' );
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to validate email or phone number single parameter request in laravel 
Php :: wordpress add menu frontend 
Php :: get vendor store url dokan 
Php :: Fehler beim Uploadtest der ausgewählten Datei. 
Php :: How To Substract And Add Hours In Laravel Using Carabon? 
Php :: run seeder command in laravel 
Php :: br2nl 
Php :: Dein Benutzer-Profil um weitere Social Media Accounts erweitern 
Php :: php getUserStateFromRequest 
Php :: undefined array key php 
Php :: php square root 
Php :: how to increment a number after concatinating it with a date function in php 
Php :: foreach loog in php 
Php :: php receive get 
Php :: php strom key 2 
Php :: veue laravel remove #/ 
Php :: null safe operator in php 
Php :: yoast seo alternative for laravel 
Php :: PHPExcel not supporting long integer value 
Php :: magento 2.4.3 how to log 
Php :: PHP soundex — Calculate the soundex key of a string 
Php :: https://stackoverflow.com/questions/58589741/angular-8-hide-divs-and-show-div-on-button-click 
Php :: page preview changes in wordpress in custom post type 
Php :: Argument 1 passed to DoctrineInflectorInflector::singularize() must be of the type string, null given, 
Php :: php cut after first sentence 
Php :: Stopping On First Validation Failure 
Php :: Remove auto generate p from category description 
Php :: php specific function to Unflatten array 
Php :: laravel helper.php session data 
Php :: How to get ID and other string in url 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =