Switch subscription, but user still have access to old subscription pages

User switch subscription, but user still have access only to old subscription articles and posts on front-page and menu

We have a "free subscription" but when user upgrade to payed subscription pages, those articles that are only available for payed subscription, are not shown on front-page or in menu. However, they are accessible if you have the direct URL.

Protected content has a lot of bugs. We report them continuously and we receive very kind replies from the support staff, but nothing ever gets repaired? That is not acceptable.

Please attend to this bug asap. Thanks in advance.

  • Michael Bissett

    Hey @Jonathan,

    I didn't forget your request, but please note, we've had a flood of tickets to deal with as of late, so it's not that we've forgotten your request, it's just that there's a lot of folks asking for help here. We're trying to get back to everyone as soon as we can. :slight_smile:

    With that said, I noticed that the Support Access you granted is giving me an invalid access token error when I try logging in, could you please revoke & re-enable Support Access, so I can have a look inside your site?

    Kind Regards,
    Michael

  • Michael Bissett

    Hey @Jonathan,

    I should point out that @Judah is a fellow member here, and not staff, he was asking this due to wanting to know if Protected Content would have issues with users switching subscriptions on his own site.

    Judah: I should also mention that the gateway in question here is a custom developed one, and not one of the default gateways. You should be fine with one of the default gateways, but should you have any issues, could you open a separate thread please? :slight_smile:

    Jonathan: Okay, back to you. :slight_smile:

    I noticed that when I tried testing the signup process (as laid out in the email you had sent to us), the payment failed for me, and I wasn't actually switched to the subscription I chose (I chose the "6 månader" subscription in my testing).

    Is this what you saw in your testing? Or did you get different results? If so, what were they?

    I'm not familiar with the PayEx gateway, are you certain that it's supposed to come up as "failed" when doing a Sandbox transaction like this? This may be something that we'll need to call in our SLS staff for (due to the nature of the situation).

    Please advise,
    Michael

  • Jonathan

    Hi,
    We made our own fix for this, an ugly fix but it works.
    Now when you upgrade your subscription from one with limited access to a subscription with more access then they get that access immediately and not when the old subscription runs out.

    Changed file: /protected-content/app/model/rule/class-ms-model-rule-post.php
    Here is the code:
    /**
    * Protect post from showing.
    *
    * Related Action Hooks:
    * - pre_get_posts
    *
    * @since 1.0.0
    *
    * @param WP_Query $query The WP_Query object to filter.
    */
    public function protect_posts( $wp_query ) {

    // Global caching variable: dirty bugfix
    global $has_access;
    if (!is_array($has_access)) {
    $has_access = array();
    }

    // List rather than on a single post
    if ( ! $wp_query->is_singular
    && empty( $wp_query->query_vars['pagename'] )
    && ( ! isset( $wp_query->query_vars['post_type'] )
    || in_array( $wp_query->query_vars['post_type'], array( 'post', '' ) )
    )
    ) {
    // Only verify permission if ruled by post by post.
    if ( MS_Model_Addon::is_enabled( MS_Model_Addon::ADDON_POST_BY_POST ) ) {

    foreach ( $this->rule_value as $id => $value ) {
    if ( $this->has_access( $id ) ) {
    $has_access[] = $id;
    $has_access = array_unique($has_access);
    } else {
    if (!in_array($id, $has_access)) {
    $wp_query->query_vars['post__not_in'][] = $id;
    }
    }
    }
    }

    $membership = $this->get_membership();
    if ( MS_Model_Membership::TYPE_DRIPPED == $membership->type ) {
    $dripped_type = $this->get_dripped_type();
    /**
    * Exclude dripped content.
    * Can't include posts, just exclude because of category clause conflict to post_in.
    * Using filter 'posts_where' to include dripped content.
    * * @todo handle default rule value.
    */
    if ( ! empty( $this->dripped[ $dripped_type ] )
    && is_array( $this->dripped[ $dripped_type ] )
    ) {
    foreach ( $this->dripped[ $dripped_type ] as $post_id => $period ) {
    if ( ! $this->has_dripped_access( $this->start_date, $post_id ) ) {
    $wp_query->query_vars['post__not_in'][] = $post_id;
    if ( $key = array_search( $post_id, $wp_query->query_vars['post__in'] ) ) {
    unset( $wp_query->query_vars['post__in'][ $key ] );
    }
    }
    }
    }
    }
    }

    do_action( 'ms_model_rule_post_protect_posts', $wp_query, $this );
    }

  • Michael Bissett

    Hey @Jonathan, glad you were able to find a workaround in the meantime! :slight_smile:

    I think it'd be best if we were to call in SLS on this, so that we can find a solution that doesn't require this sort of alteration. To help them out with this, could you please send in the following:

    - Mark to my attention, the subject line should contain only: ATTN: Michael Bissett
    - Do not include anything else in the subject line, doing so may delay our response due to how email filtering works.
    - Link back to this thread
    - Include a copy of the PayEx gateway
    - Include any relevant details for this

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    https://premium.wpmudev.org/contact/

    Please note, that our SLS staff have quite a bit on their plate presently, so this may take longer than usual. But we'll do our best to look for a solution that doesn't require a core change here.

    Thanks! :slight_smile:

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.