• Hi,
    is it possible to invoke the shortcode with a specific email address as attribute? are there any other attributes that could be used? if not, could be added through filters?
    e.g.: [download_after_email id=”123456″ email=”[email protected]”]

    Many thanks for your useful plugin,
    Florian

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author mkscripts

    (@mkscripts)

    Hi Florian,

    You are welcome!

    Yes it is possible to invoke the shortcode with your own custom attributes. It is advisable to prefix your attribute so that the name does not conflict with existing or future attributes of the plugin. Currently only “id” and “css” are in use.

    You could use your custom attribute, for example, to add a hidden field to the download form and use its value after the submission of the download form. In the code example below let’s say we have the following shortcode:

    [download_after_email id=”123456″ cst_email=”[email protected]”]

    add_filter( 'dae_shortcode_html_fields', 'cst_add_hidden_download_form_field', 20, 3 );
    function cst_add_hidden_download_form_field( $html_fields, $file_name, $atts ) {

    if ( empty( $atts['cst_email'] ) ) {
    return $html_fields;
    }

    $html_fields .= '<input type="hidden" name="cst_email" value="' . esc_attr( $atts['cst_email'] ) . '" />';

    return $html_fields;

    }

    add_action( 'dae_after_send_downloadlink', 'cst_action_hidden_download_form_field' );
    function cst_action_hidden_download_form_field( $subscriber_id ) {

    if ( empty( $_POST['cst_email'] ) ) {
    return;
    }

    $cst_email = $_POST['cst_email'];

    }

    Kind regards,
    Team Download After Email

    Thread Starter florynx

    (@florynx)

    Thanks for the above solution!
    Is there a way to manually insert a subscriber in backend (email and download id) via php code snippet or WP admin dashboard?

    • This reply was modified 4 weeks ago by florynx.
    Plugin Author mkscripts

    (@mkscripts)

    To add a new subscriber:

    $subscriber_id = DAE_Subscriber::insert( array(
    'email' => '[email protected]'
    ) );

    A new subscriber always comes with a new download link. To create a download link:

    $file = 'test.pdf';
    $form_content = ''; // This is normally a copy of the HTML download form content (GDPR)

    $link_id = DAE_Subscriber::insert_link( $subscriber_id, $form_content, $file );

    The $link_id can be used to generate a nonce which is needed to create the actual download link. You can find this code in ../includes/shortcodes.php.

    Kind regards,
    Team Download After Email

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.