Support » Plugin: If Menu - Visibility control for Menu Items » RCP Multiple Subscriptions Fix

  • adunsulag

    (@adunsulag)


    Hi we recently upgraded our restrict content pro plugins and saw that it supports multiple subscriptions. The latest If-Menu plugin uses the deprectated rcp_get_subscription_id which only returns one of the subscriptions instead of checking against all of the subscriptions a user has. The following code snippets fix that problem. It would be great if this could be incorporated into the next version of the plugin. Hope this helps someone else.

    In file: src/conditions-multiple-options.php lines 432-438 replace

    
    $userId = get_current_user_id();
    
    if (!$userId) {
      return false;
    }   
    
    return in_array(rcp_get_subscription_id($userId), $selectedLevels);
    

    With this

    
    $current_customer_id = 0; // 0 gets current customer
    
    $level_ids = rcp_get_customer_membership_level_ids( $current_customer_id );
    // grab all the items that are the same between the customer levels and menu condition levels (array_intersect) return true if there is at least one element in comment between the two.
    return ! empty ( array_intersect( $level_ids, $selectedLevels ) );
    
  • The topic ‘RCP Multiple Subscriptions Fix’ is closed to new replies.