Custom Post types with Pay-Per-View

i have installed pay per view and configured it correctly, the plugin works on regular posts and pages, however i will be using it on my custom post types, and it will not work on these pages. i am using Advanced Custom Post Types plugin to make my post types. I tried to implement your "customization" edits to the theme files but it would not work and caused a fatal error. it seems to conflict with the pluggable.php included in wp-includes.

please help

  • dreamraven

    hello,

    so what happens is that when i add the shortcode to the content within a custom post type, the content and the shortcode appear, with no buttons. this is both as admin, and logged out completely and as another user, in multiple browsers with caches cleared.

    if i add the shortcodes in regular pages or posts it shows up fine. with buttons and all.

    so i tried to add the customizations to my custom post type templates ie:

    <?php
    if ( function_exists( 'wpmudev_ppw' ) )
    echo wpmudev_ppw( custom_description() );
    else
    echo custom_description();
    ?>

    with my own custom template calls inserted where it says "custom_description()"

    I then went to my child themes functions. php and added the function that is in the example ie:

    <?php
    function my_ppv_customization( ) {
    global $ppw, $post;
    if ( !is_object( $ppw ) || !is_object( $post ) ) return;
    // Call this only for a post/page with ID 123. Change as required.
    // If you omit this line, js and style files will be added to all of your pages and caching will be disabled. So it is recommended to keep and modify it for the pages you are using.
    if ( $post->ID != 123 ) return;
    $ppw->load_scripts_styles();
    }
    add_action( 'template_redirect', 'my_ppv_customization', 2 );
    ?>

    with my own page id added where it says "123"

    at this point the site threw up this error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/shumbare/public_html/banakuma.org/wp-content/themes/BanaKuma/functions.php:8) in /home/shumbare/public_html/banakuma.org/wp-includes/pluggable.php on line 876

    I also tried to edit the code from the example and call the wpmudev_ppw function instead of the my_ppv_customization( ) function.

    this created a fatal error, saying that the wpmudev_ppw was already declared in pay-per-view.php on line 2487

    this is when i decided to write you....

  • Arnold

    Let's work through this a piece at a time. You say you are using the Advanced Custom Post Types plugin. I don't find a plugin with that name in Google. I find a plugin called Advanced Custom Fields. Can you give me the specifics on the plugin your using? An Url to download t would be good.

    Failing that I tried it with CustomPress to make a custom type and had no trouble with it. So I don't think it's Custom types per se.

    The warning your getting Warning: Cannot modify header information - headers already sent by (output started ...) can happen for a lot of reasons. Some as simple as text before the opening <?php or trailing spaces after the closing ?> in a PHP file.

    Your last error is simply that you had two different finctions with the same name.

  • dreamraven

    Thank you so much for responding. I am sorry i gave you the wrong name for the Plugin.
    It is called Custom Post Types UI here is the URL http://wordpress.org/plugins/custom-post-type-ui/

    I am using it in conjunction with Advanced Custom Fields
    http://www.advancedcustomfields.com/

    Basically what i did was create a Custom template to display my Custom Post type that is populated by my Custom Fields.

    if that all makes sense. :slight_smile:

    I have double checked the code i had and there are no extra spaces or characters.

    Should I try your Custom Press pluign? or do you have another suggestion? let me know what is the best thing to do from here.

    thanks

  • Arnold

    I added the Custom Post Type UI and made a post of the custom type and that worked fine with PPV.

    I added Custom Fields and that also works fine. So something is specific to your setup. Are you using the 2012 theme for testing?

    One other thing you might check which can mess things up. /all your script files must be UTF-8 encoded. A gotcha with this is some editor start the file with a "Byte Order Mark" (BOM) which is three characters that specify the byte order on two byte characters. In Wordpress the file must not have the BOM marker. The very first character should be a "<php" when viewed in a hex editor.

    Note that when using Custom types that you need to set the fields for the post type. I made a post type "portfolio" and set this for the field group.

  • dreamraven

    thank you again.

    right now, i was testing n my child theme, as the custom templates i made to house my custom fields and post types, are in that theme. when i switched to the 2012 theme they all went away. so i would need to add those template files to the 2012 theme for them to show up .

    my custom types are all configured correctly and the field groups are pointing to the right custom type.

    where can i check these script files?

    and maybe you can step me through the process again of adding the codes to my theme files from the customization.

    right now i am adding this code to my custom template where the custom fields are

    <?php
    if ( function_exists( 'wpmudev_ppw' ) )
    echo wpmudev_ppw( the_field('tutorials') );
    else
    echo the_field('tutorials');
    ?>

    and in my child theme functions file i am adding (with nothing else before or after it) and 863 is the Post id for the post that has the PPV shortcode on it.

    <?php
    function my_ppv_customization( ) {
    global $ppw, $post;
    if ( !is_object( $ppw ) || !is_object( $post ) ) return;
    // Call this only for a post/page with ID 123. Change as required.
    // If you omit this line, js and style files will be added to all of your pages and caching will be disabled. So it is recommended to keep and modify it for the pages you are using.
    if ( $post->ID != 863 ) return;
    $ppw->load_scripts_styles();
    }
    add_action( 'template_redirect', 'my_ppv_customization', 2 );
    ?>

    at that point it again puts out this error

    Warning: Cannot modify header information - headers already sent by (output started at /home/shumbare/public_html/banakuma.org/wp-content/themes/BanaKuma/functions.php:11) in /home/shumbare/public_html/banakuma.org/wp-includes/pluggable.php on line 876

    what am i doing wrong?

    would you like to look at my set-up?

  • Arnold

    If you are putting the code above in <?php ?> tags in the functions file, does it actually need them? The bottom of the twentytwelve theme looks like.

    /**
     * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
     *
     * @since Twenty Twelve 1.0
     */
    function twentytwelve_customize_preview_js() {
    	wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true );
    }
    add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );

    If you added the above to it with the <?php ?> it would be an error because you are already in the php section.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.