i dont know how to integrate the plugin pay per view.

i dont know how to integrate the plugin pay per view.

i have to protect dynamic fields directly on template files.

i used wp job manager and wanted protect some fields.

For example in my template file i have this which i would like protect:

<div class=”salary”>Salary : <?php echo get_post_meta($post->ID, ‘_job_salary’, true); ?> €</div>

<div class=”contact”>Contact : <?php echo get_post_meta($post->ID, ‘_job_contact’, true); ?> €</div>

how can i protect it ?

thanks

  • richard03200
    • Flash Drive

    thanks for your quickly answer but i don’t understand all..

    what i have to do for pay-per-view.php at the line:

    add_filter( ‘the_content’, array( &$this, ‘content’ ), 8 );

    i have to remove this or remplace by another code?

    where i put this?

    global $ppw;

    $my_custom_field_ppv = $ppv->content( $my_custom_field_content );

    // Echo the content from our custom field after we pass it through PPV

    echo $my_custom_field_ppv;

    in function.php of my template?

    sorry but i’m not developper thanks for your support

  • richard03200
    • Flash Drive

    One can explain me please?

    i have an error when i put

    global $ppw;

    $my_custom_field_ppv = $ppv->content( $my_custom_field_content );

    // Echo the content from our custom field after we pass it through PPV

    echo $my_custom_field_ppv;

    in my function.php file

    thanks

  • richard03200
    • Flash Drive

    Hello,

    i come back to you because i have tryed an other solution, it’s may work but not totally because i can protect only one custom field and in have 3,4 custom fields to protect.

    my code:

    <?php

    if ( function_exists( ‘wpmudev_ppw_html’ ) ) {

    $my_custom_field_content = get_post_meta($post->ID, ‘_job_salary’, true);

    $id = 1;

    $description = ‘test’;

    $price = ‘0.01’;

    echo wpmudev_ppw_html( $my_custom_field_content, $id, $description, $price );

    }

    ?>

    have you an idea to help me please ?

    thanks

  • richard03200
    • Flash Drive

    when i do in my custom post file .php :

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    $id = 1; // An optional unique id if you are using the function more than once on a single page
    $description = 'test'; // Optional description of the protected content
    $price = '0.001'; // Optional price for a single view. If not set, price set in the post will be applied. If that is not set either, Unit Price in the Global Settings will be used.
    echo wpmudev_ppw_html( $test, $id, $description, $price );
    }
    ?>

    i have this error :

    There was a problem connecting to PayPal to setup your purchase. Please try again.

    10401 – Transaction refused because of an invalid argument. See additional error messages for details. – Order total is invalid.

    10431 – Transaction refused because of an invalid argument. See additional error messages for details. – Item amount is invalid.

    i meet often this error too.. one can help me?

    thanks

    [EDITED by moderator to see code more clearly. :slight_smile: ]

  • DavidM
    • DEV MAN’s Mascot

    Hi @richard03200,

    Thanks for your clarifications. The bit of code you provided would actually be for using Pay Per View to provide access to just the custom fields.

    Is that what you wanted? Or did you want to simply display the custom fields after a user has already purchased access to the post?

    From what I can see, you could easily use a simple snippet like this:

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    global $ppw;
    $my_custom_field_ppv = $ppv->content( $test );
    // Echo the content from our custom field after we pass it through PPV
    echo $my_custom_field_ppv;
    }
    ?>

    Then you can simply provide paid access to the very post itself and once paid for, the user would then see the custom field in the page where that’s included.

    Would something like that work for you?

    Cheers,

    David

  • richard03200
    • Flash Drive

    thanks for your answer David,

    yes i would like just protected 3 or 4 custom fields in the posts

    i’ve tried your code but i have this error now:

    Fatal error: Call to a member function content() on a non-object in (…:wink: on line 47

    line 47 = $my_custom_field_ppv = $ppv->content( $test );

    thanks

  • DavidM
    • DEV MAN’s Mascot

    Hi there @richard03200,

    Sorry, I should have double-checked when I copy-pasted this. The first $ppv was actually $ppw. Thus that was causing the error.

    Could you please try this instead?

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    global $ppw;
    $my_custom_field_ppv = $ppw->content( $test );
    // Echo the content from our custom field after we pass it through PPV
    echo $my_custom_field_ppv;
    }
    ?>

    Thanks,

    David

  • DavidM
    • DEV MAN’s Mascot

    Hi there @richard03200,

    Hmm, could you try this one last snippet?

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    global $ppw;
    if ( !is_object( $ppw ) )
    return;
    $my_custom_field_ppv = $ppw->content( $test );
    // Echo the content from our custom field after we pass it through PPV
    echo $my_custom_field_ppv;
    }
    ?>

    It’s got an extra check to ensure $ppw is an object so hopefully that’ll sort it right there. :slight_smile:

    Thanks,

    David

  • richard03200
    • Flash Drive

    Now is ok i have the button for the pay buy paypal and protect my field :slight_smile:

    but now i have this error:

    There was a problem connecting to PayPal to setup your purchase. Please try again.

    10401 – Transaction refused because of an invalid argument. See additional error messages for details. – Order total is invalid.

    10431 – Transaction refused because of an invalid argument. See additional error messages for details. – Item amount is invalid.

    thanks

  • DavidM
    • DEV MAN’s Mascot

    Hi @richard03200,

    Glad that initial item is sorted, now those errors definitely don’t seem right. Could you let me know how you’re handling the payment process?

    Have you provided the price through the post editor? Or maybe through a shortcode or other custom code?

    If possible, could you provide a screenshot of the editor page where you’ve specified that price?

    Thanks,

    David

  • richard03200
    • Flash Drive

    i have just put in general setting of ppv.

    maybe i do it wrong and i have to use shortcode for my custom field?

    like the example:

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $html = '<iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;http://www.youtube.com/embed/-uiN9z5tqhg&quot; frameborder=&quot;0&quot; allowfullscreen></iframe>'; // html code to be protected (required)
    $id = 1; // An optional unique id if you are using the function more than once on a single page
    $description = 'video'; // Optional description of the protected content
    $price = '1.50'; // Optional price for a single view. If not set, price set in the post will be applied. If that is not set either, Unit Price in the Global Settings will be used.
    echo wpmudev_ppw_html( $html, $id, $description, $price );
    }
    ?>

  • richard03200
    • Flash Drive

    i have advanced a little bit (i think). for connect with paypal it seems okay with this code

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    $test2 = get_post_meta( get_the_ID(), '_job_email', true );
    $price = '0.01';
    $description = 'test';
    global $ppw;
    if ( !is_object( $ppw ) )
    return;
    $my_custom_field_ppv = $ppw->content( $test, $test2 );
    // Echo the content from our custom field after we pass it through PPV
    echo wpmudev_ppw_html ( $my_custom_field_ppv, $id, $description, $price ) ;
    }
    ?>

    i don’t know if this is very optimized (if it doesnt can you correct me please?)

    My problem here is for the next protect fields, you can see on my code i’ve tried with $test2 but when i paid i just see the $test (for the job_salary)

    have you an idea about it?

    thanks

  • richard03200
    • Flash Drive

    hello,

    i have tried this but it doesnt work too, one have an idea for protect 3,4 fields ?

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    $test2 = get_post_meta( get_the_ID(), '_job_email', true );
    $price = '0.01';
    $description = 'test';
    global $ppw;
    if ( !is_object( $ppw ) )
    return;
    $my_custom_field_ppv = $ppw->content( $test );
    $my_custom_field_ppv_2 = $ppw->content( $test2 );
    // Echo the content from our custom field after we pass it through PPV
    echo wpmudev_ppw_html ( $my_custom_field_ppv, $my_custom_field_ppv_2, $id, $description, $price ) ;
    }
    ?>

    thanks

  • DavidM
    • DEV MAN’s Mascot

    Hi @richard03200,

    You actually can use the default functionality of the plugin for the payment aspect. The custom code we’ve done here should be just for the custom fields.

    And given the code you’ve mentioned, I believe this is more what you’re looking for:

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    $test2 = get_post_meta( get_the_ID(), '_job_email', true );
    global $ppw;
    if ( !is_object( $ppw ) )
    return;
    $my_custom_field_ppv = $ppw->content( $test );
    $my_custom_field_ppv_2 = $ppw->content( $test2 );
    // Echo the content from our custom field after we pass it through PPV
    echo $my_custom_field_ppv;
    echo $my_custom_field_ppv2;
    }
    ?>

    To reiterate though, it sounds like all you need to do is just use the standard payment features in the post editor screen.

    Then using that bit of code in the template file, when the user pays, they’ll get access to the custom fields.

    Does that make sense?

    Cheers,

    David

  • richard03200
    • Flash Drive

    Sorry, my fault.. it seems work now the custom fields are protected but when i want pay to see content i have this error message:

    There was a problem connecting to PayPal to setup your purchase. Please try again.

    10401 – Transaction refused because of an invalid argument. See additional error messages for details. – Order total is invalid.

    10431 – Transaction refused because of an invalid argument. See additional error messages for details. – Item amount is invalid.

    And i dont have with my previous code where i define the price in the code.

    Do you know why?

    Thanks

  • DavidM
    • DEV MAN’s Mascot

    Hey there @richard03200,

    That error message shouldn’t show if you’re using the standard Pay Per View methods of payment, where you specify the payment options on a per-post basis, for example.

    The “invalid argument” seems to indicate you’re using custom code somewhere and haven’t provided the correct arguments within that code.

    Could you please let me know how it works without any other custom code except that custom field code mentioned above?

    Thanks,

    David

  • richard03200
    • Flash Drive

    Hello David,

    what i have to show you for help me?

    i dont understand why i have this error? what i have to do?

    i have created the PayPal API Credentials.

    With the code you give me i have this error :

    There was a problem connecting to PayPal to setup your purchase. Please try again.

    10401 – Transaction refused because of an invalid argument. See additional error messages for details. – Order total is invalid.

    10431 – Transaction refused because of an invalid argument. See additional error messages for details. – Item amount is invalid.

    With this code :

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    $test2 = get_post_meta( get_the_ID(), '_job_email', true );
    $price = '0.01';
    $description = 'test';
    global $ppw;
    if ( !is_object( $ppw ) )
    return;
    $my_custom_field_ppv = $ppw->content( $test, $test2 );
    // Echo the content from our custom field after we pass it through PPV
    echo wpmudev_ppw_html ( $my_custom_field_ppv, $id, $description, $price ) ;
    }
    ?>

    i dont have this error and it send the visitor on paypal but i can’t protect 2 fields.

    I don’t understand what i can show you more, i am totally lost..

  • DavidM
    • DEV MAN’s Mascot

    Hi @richard03200,

    Sorry if that seemed confusing at all but let’s see how we can get that cleared up really quickly!

    Could you please try removing all custom code that you’ve added so far?

    And you can then try providing the Pay Per View features through a particular post or page and see how it works there.

    Could you let me know how that works?

    Once that’s working, we can try proceeding with that added code. I believe you have other code added that’s generating that error message so this will help us get that sorted. :slight_smile:

    Thanks,

    David

  • richard03200
    • Flash Drive

    Hello David,

    sorry for my late answer.

    I have the same error when i use it for one new post for example.

    I have this :

    “There was a problem connecting to PayPal to setup your purchase. Please try again.

    10401 – Transaction refused because of an invalid argument. See additional error messages for details. – Order total is invalid.

    10431 – Transaction refused because of an invalid argument. See additional error messages for details. – Item amount is invalid.”

    What can be this “invalid argument” ?

    Thanks

  • Tyler Postle
    • CGO

    Hey Richard,

    Just to make sure here, you have removed all custom code you’ve added so far? Even code you may have added on your own?

    It looks like it’s saying that the order total and item amount are invalid. Right now we just want to get the default setup working then we can look to add custom code :slight_smile:

    Let us know if you have removed all your custom code at this point.

    Cheers,

    Tyler

  • richard03200
    • Flash Drive

    Thanks all for your help,

    but now just one thing important for me, for protect one custom field its okay, but for more it doesnt work. my code:

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    $test2 = get_post_meta( get_the_ID(), '_job_email', true );
    $price = '0.01';
    $description = 'test';
    global $ppw;
    if ( !is_object( $ppw ) )
    return;
    $my_custom_field_ppv = $ppw->content( $test );
    $my_custom_field_ppv_2 = $ppw->content( $test2 );
    // Echo the content from our custom field after we pass it through PPV
    echo $my_custom_field_ppv;
    echo $my_custom_field_ppv2;
    }
    ?>

    when i paid i see the $my_custom_field_ppv but not the second protect field $my_custom_field_ppv2

    Do you know why?

    Thanks

  • aristath
    • Recruit

    Hello again @richard03200,

    Can you please try the following and let me know if that works for you?

    It’s just a different syntax for your above code, but you never know…

    <?php
    if ( function_exists( 'wpmudev_ppw_html' ) ) {
    $test = get_post_meta( get_the_ID(), '_job_salary', true );
    $test .= ' ' . get_post_meta( get_the_ID(), '_job_email', true );
    $price = '0.01';
    $description = 'test';
    global $ppw;
    if ( !is_object( $ppw ) )
    return;
    $my_custom_field_ppv = $ppw->content( $test );

    // Echo the content from our custom field after we pass it through PPV
    echo $my_custom_field_ppv;
    }
    ?>

    Please advise,

    Ari.

  • richard03200
    • Flash Drive

    Great its work thanks!

    but now i dont need that echo $my_custom_field_ppv2; isnt it?

    last question about it (if we cant no problem), with 2 protect field in one same echo its hard to read when we have paid. For example my custom fields hidde salary and email then i have this result:

    1000 myemail@email.fr

    we can’t use like this:

    echo $my_custom_field_ppv;
    echo $my_custom_field_ppv2;

    Thanks for your support

  • aristath
    • Recruit

    Hello again!

    You’re right, I just forgot to delete that line from my above reply. I have now corrected that. :slight_smile:

    As for your other question, if you notice on line 4 of my code above I start the line with this:

    $test .= ' ' . and then the rest of the code.

    That adds a space between the 2 fields (the ‘ ‘ in there have the space), so you can add whatever separator you need in those single-quotes.

    I hope that helps!

    Cheers,

    Ari.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.