Automatic Pay with a Like for custom field for custom type

I have a custom type I made with CustomPress, called "Project". For each project, I have the field "Download URL", which I want protected by the Pay with a Like plugin. I want only the URL protected, all else visible.

So I figured out I must do my custom template for project and put the download URL data within Pay with a Like shortcode or something like that.

However, Pay with a Like generates a random ID when I use the shortcode on GUI. So, how can I create such ID to use it in my custom template to guard the download URL of each project?

Or, what solution might be there for protecting a custom field in a custom template?

Thanks in advance :smiley:.

  • Paul

    @Carlos Ramos,

    However, Pay with a Like generates a random ID when I use the shortcode on GUI. So, how can I create such ID to use it in my custom template to guard the download URL of each project?

    The ID from the GUI/TinyMCE button is just a very long number. If you are trying to use PWAL from your template you can just generate your own unique ID number from whatever source. and use it as part of the do_shortcode() function call.

    When you build the shortcode there are a few parameters you can use.

    'id' - Some unique ID you assign. Ensure this is the same for all visitors for this post/shortcode set.
    'post_id' - Used to pull in options you would normally set via the post editor metabox.
    'wpautop' - Controls the WordPress auto wrap <p></p> filter.
    'content_reload' - See the post form metabox. Values can be reload or ajax
    'container_width' - With of the PWAL box for this shortcode.
    'description' - Description shown to the visitor above the PWAL buttons.

  • Carlos Ramos

    Sup,

    Here is the code I used for my solution:

    //Se obtiene el valor del vínculo con el código fuente (shortcode de campo de CustomPress).
    $vinculo = do_shortcode('[ct id="ct_Vnculo_de__text_477c" property="value"]');
    //Se crea el botón (shortcode de botón de Elegant Themes).
    $boton = do_shortcode("[button link='$vinculo' type='icon'] Descargar código fuente del proyecto [/button]");
    //Envolvimiento del botón para mostrar tras un 'Me gusta' (shortcode de Pay With A Like).
    $idPost      = get_the_ID();
    $idGenerado  = get_the_date('YmdHi');
    $descripcion = '¡Comparte en alguna red social para descargar el código fuente de ' . the_title('', '', false) . '!';
    $codigoPWAL = do_shortcode("[pwal id='$idGenerado' post_id='$idPost' description='$descripcion' content_reload='reload'] $boton [/pwal]");
    //Mostrar el código.
    echo $codigoPWAL;

    So, the plugin has to be enabled on the custom post, with the excerpt method "Use selection tool" selected. And it will take the generated ID with 12 digits from the date in the format "YmdHi".

    One question, however: the content reload will be taken from the code shortcode or the custom type settings meta box? Thanks in advance :smiley:.

  • Paul

    @Carlos Ramos,

    The PWAL shortcode looks good. Yes, the number for ID can be 10-12. Try to keep it with the realm of an integer.

    One question, however: the content reload will be taken from the code shortcode or the custom type settings meta box?

    Great question. If you provide the content_reload parameter within the shortcode then it will be used. If not the shortcode processing looks for the post_id parameter to derive the values. If you don't provide the post_id the shortcode process will pull the values from the default settings.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.