WordPress.org

Forums

Advanced Custom Fields
Advanced Custom Fileds in mail body are empty with Subscribe2 (1 post)

  1. dobst
    Member
    Posted 11 months ago #

    Hello,

    I'm running the latest version of ACF and Subscribe2 and try to add custom fields (from the Advanced Custom Fields plugin) to the mail body.

    I'm using the s2_html_email and s2_plain_email filters (S2-API) and a custom function to modify the mail body. This works if the post is saved before it's published. If it's published directly without have been saved as draft the get_the_ID() and equivalents are still empty and I can't post the meta data with

    get_post_meta(get_the_ID(),'<advanced custom field>',true);

    This problem is very similar to
    http://wordpress.org/support/topic/subscribe2-and-custom-fields?replies=5 and
    http://wordpress.org/support/topic/include-custom-fields-in-post-e-mails?replies=4

    Also ideas to force the meta data to be written to the db before the post is published are without success:

    function save_details() {
     global $post;
     update_post_meta($post->ID, "begin_date", $_POST["begin_date"]);
     update_post_meta($post->ID, "end_date", $_POST["end_date"]);
     add_post_meta($post->ID, 'begin_date', $_POST["begin_date"], false);
     add_post_meta($post->ID, 'end_date', $_POST["end_date"], false);
    }
    add_action('new_to_publish', 'save_details');
    add_action('pending_to_publish', 'save_details');
    add_action('draft_to_publish', 'save_details');
    add_action('auto-draft_to_publish', 'save_details');
    add_action('future_to_publish', 'save_details');
    add_action('private_to_publish', 'save_details');
    add_action('trash_to_publish', 'save_details');

    https://wordpress.org/plugins/subscribe2/

Reply

You must log in to post.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.