API logins & subscription duration

Hello,

We would like to develop a site that has pay per view, daily pass and subscriptions.
The pay-per-view plugin seems to be what we need, however there are 2 things I would like to enquire about:
1. API logins and subscriptions: why is it necessary to have a facebook or twitter account? We are in China, where these 2 sites are inaccessible. Is there a way to bypass this?
2. Subscriptions: Is there any way to provide several packages? Right now there is only one option for subscriptions, with only one duration/price combination. How hard would it be to allow several subscription options?

Thank you and best regards,

  • Jack Kitterhing

    Hi there @crystalasia

    I hope you are well today and thank you for your questions.

    1: You don't need to use Facebook and/or twitter, it's just there if you wanted to use it :slight_smile: By default Pay Per View would be used with a normal account on your website or a one off payment.

    2: With the subscriptions, would that be for Pay Per View? I'm afraid currently it's not possible to add additional subscriptions to Pay Per View, though you may want to take a look at our membership plugin for subscriptions, you can find that here https://premium.wpmudev.org/project/membership/

    Thank you for being a WPMU DEV member!

    Kind Regards
    Jack.

  • crystalasia

    Hello Jack,

    About point 1, if I use Daily Pass or Recurring subscription without ticking "Enables login to website using Facebook and Twitter.", the admin panel gives me the following error: "[Pay Per View] If you are using Daily Pass or Recurring Subscriptions, you need to enable and set API logins." - it seems it is required, how do I bypass that?

    Haha, for point 2 I agree with you about naming conventions - however the pay-per-view plugin does provide the recurring subscription option, so it's a bit confusing...
    Anyway, the question now would be: how to make sure that a post restricted by pay-per-view becomes accessible once the member with the appropriate membership is authenticated?
    Basically, the site I am trying to develop needs to have pay-per-view and subscriptions, to cover different types of buying habits. Would there be any conflict between the 2 plugins?

    Best,

  • Jack Kitterhing

    Hi there @crystalasia

    I hope you are well today, sorry to see my original response was unhelpful, I apologize about that and appreciate the feedback to make my future responses better :slight_smile:

    Back to the issue :slight_smile:

    1: In WordPress admin > Pay Per View > Pay Per View scroll down to API settings and make sure accept API logins in unticked, as you can't have people logging in for facebook and twitter without setting the API. But then you are correct that you can't use recurring subscriptions as WordPress wouldn't have anything to attach the subscription to, I'll flag the lead developer for his valuable input on that :slight_smile:

    2: There shouldn't be any conflicts between the plugins both should work just fine with each other, though there is no direct integration between the plugins :slight_smile:

    Thank you for being a WPMU DEV member! I'm here to help if you have any problems.

    Kind Regards
    Jack.

  • crystalasia

    Nice guys, thank you very much for the support!

    Another question: how long would it take/much would it cost to integrate membership with pay-per-view?

    We can do it ourselves and contribute to the community (I just need your guidance where to place the code) or we can agree on a financial compensation.

    The idea: if I am authorized to see the content with my current level of membership, then pay-per-view considers me as part of the "Authorized users see full content".

    I see it like this roughly (functions names are made up and it's just algorithm concept):

    // When building the admin panel
    if(plugin_exists(membership)) {
    // grab the access levels created in membership admin panel and display them under "User level where authorization starts"
      add_options_to_select_authorized_access_levels();
    }
    
    //When the admin form is saved
    function form_submit() {
    
    [...]
    
    if(plugin_exists(membership)) {
      save_options_authorized_access_levels($options);
    }
    
    [...]
    
    }
    
    //In the frontend, to control the access restriction
    if(!(authorized_role($user) || authorized_access_level($user))) {
      restict_access($post)
    }

    Thanks in advance!

  • crystalasia

    Ok, after digging a bit more, there is a way to assign a role to a WP to members with membership module, which makes it easy to combine with "User level where authorization starts".
    However, the roles listed in "User level where authorization starts" do not take into account additional roles created by the code, or plugins like "User Role Editor".

    Here is the code to make it work - tested on our end. I think it would be a good improvement for flexibility - replace:

    <select name="level">
    															<option value="editor" <?php if ( $this->options['level'] == 'editor' ) echo "selected='selected'"?>><?php _e('Editor','ppw')?></option>
    															<option value="author" <?php if ( $this->options['level'] == 'author' ) echo "selected='selected'"?>><?php _e('Author','ppw')?></option>
    															<option value="contributor" <?php if ( $this->options['level'] == 'contributor' ) echo "selected='selected'"?>><?php _e('Contributor','ppw')?></option>
    															<option value="subscriber" <?php if ( $this->options['level'] == 'subscriber' ) echo "selected='selected'"?>><?php _e('Subscriber','ppw')?></option>
    														</select>

    By:

    <select name='level'>
    														<?php
    															global $wp_roles;
    															$all_roles = $wp_roles->roles;
    
    															// Preset variables
    															$p = ''; $r = '';
    
    															foreach ( $all_roles as $role => $details ) {
    																$name = translate_user_role($details['name'] );
    																if ( $this->options['level'] == $role ) { // preselect specified role
    																	$p .= "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
    																} else {
    																	$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
    																}
    															}
    															echo $p . $r;
    														?>
    														</select>
  • crystalasia

    To complete that, in the backend:

    /**
    		* Checks if user is authorised by the admin
    		*/
    		function is_authorised() {
    			global $current_user;
    
    			if ( $this->options['authorized'] == 'true' && is_user_logged_in() && !current_user_can('administrator') ) {
    				if ( in_array( $this->options['level'], $current_user->roles ) )
    					return true;
    				// if ( $this->options['level'] == 'subscriber' && current_user_can( 'read' ) )
    				// return true;
    				// else if ( $this->options['level'] == 'contributor' && current_user_can( 'edit_posts' ) )
    				// return true;
    				// else if ( $this->options['level'] == 'author' && current_user_can( 'edit_published_posts' ) )
    				// return true;
    				// else if ( $this->options['level'] == 'editor' && current_user_can( 'edit_others_posts' ) )
    				// return true;
    			}
    			return false;
    		}

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.