Disable drip content based on user_id

Home Forums Legacy Support Support queries How-to & Troubleshooting Disable drip content based on user_id

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #212475
    erickpaulino
    Spectator
    Hi, I need to disable drip content for old users that I am importing from another LMS. I have tried to add the code below, based on users IDs (old users have id smaller than 8863) but it is not working. Can you please take a look and help me?   add_filter('wplms_course_drip_legacy_users','dripLegacy',10,2); function dripLegacy($drip,$course_id){ if(!is_user_logged_in()) return $drip;   $user = wp_get_current_user(); if(wplms_user_course_active_check($user_id,$course_id) && $user_id <= '8863'){ $drip = 'H'; } return $drip; };   Thanks, Erick
    #212478
    erickpaulino
    Spectator
    Hello guys, I found the solution. I made two mistakes:
    1. Used a non-existent filter name;
    2. Used $user_id instead of $user->ID.
    Can you please explain to me why it didn't work with $user_id but worked with $user->ID ? Thank you! PS: Below is the code that is working =============== add_filter('wplms_course_drip_switch','dripLegacy'); function dripLegacy($drip,$course_id){ if(!is_user_logged_in()) return $drip; $user = wp_get_current_user(); if(wplms_user_course_active_check($user_id,$course_id) && $user->ID <= 8862){ $drip = 'H'; } return $drip; };
    #212568
    logan
    Member
    Hello, refer this: https://codex.wordpress.org/Function_Reference/wp_get_current_user because $user = wp_get_current_user(); returns an object. if you want to access any of its value then you have to write it in a correct form by passing a valid parameter or key. $user->ID: here user is a whole variable containing a list of objects. if you want to access any of its element, then you have to pass its respective key.
    #212569
    logan
    Member

    As this issue is well explained, listened to and understood by the user. on his confirmation, I am closing this topic.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Disable drip content based on user_id’ is closed to new replies.