WordPress.org

Ready to get started?Download WordPress

Forums

Subscribe To Comments Reloaded
[resolved] Automatically subscribe from custom field (10 posts)

  1. mrarrow
    Member
    Posted 3 years ago #

    Hi

    So my guest/casual website visitors are able to ask Questions by filling out a Gravity Form which simply creates a categorised post. One of the required fields in the front-end form is for the visitor to complete their email address which is subsequently stored as a custom field for that post.

    Is there anyway to enable Subscribe to Comments Reloaded to use that custom field to automatically subscribe that email address to any further comments on the respective post? So rather than a user then having to actively visit that post (once approved) and type in their email address manually.

    I would clearly put the required privacy warnings in the form before the user submitted it.

    I had something _similar_ set up in TDO Mini Forms and the original Subscribe to Comments plugin but Subscribe to Comments Reloaded seems a lot more powerful.

    Thanks in advance. Any thoughts or suggestions?

  2. camu
    Member
    Plugin Contributor

    Posted 3 years ago #

    Hi there,

    what you can do is to customize your Forms manager so that it adds a new row into my plugin's table wp_subscribe_reloaded, with the proper information for each column. Subscribe to Comments Reloaded won't notice the difference and will process those subscriptions accordingly.

    Camu

  3. mrarrow
    Member
    Posted 3 years ago #

    Awesome thanks! As simple as that. I'll post anything back once I've worked out how to do it.

    Many thanks

  4. camu
    Member
    Plugin Contributor

    Posted 3 years ago #

    sure, keep us posted! Thanks!

  5. mrarrow
    Member
    Posted 3 years ago #

    So, I've already written a function which sends an email (using the address in the custom field) to confirm that the submitters post is now published. I figured I could bolt on your suggestion to this function.

    I also thought I could modify one of your own functions to take advantage of code further down your plugin and to keep it compatble with any plugin updates. The one I spotted was add_subscription($_email, $_status, $_post_ID);

    So, I pasted your function into my themes functions.php and changed those variables to match ones I'm already calling in my own function (namely referencing the correct custom field and retrieving the post ID). Briefly these exra lines in my functions.php file are:

    global $post;
    $email_to = get_post_meta($post->ID, 'Author Email', true);
    .........
    include 'http://<nameofdomain>/wp-content/plugins/subscribe-to-comments-reloaded/subscribe-to-comments-reloaded.php';
    add_subscription($email_to, $_status, $post->ID);

    I thought that this would work, but depending on where I put thos last two lines (the include line and add_subscription, it either white-screens come publishing, or simply ignores that code. Mmy other custom function continues to work fine, so its definitely the monkey-business I've been doing with this!

    This should work in principle though shuoldn't it - over-riding one of your functions with my own values?

    Any thoughts much appreciated!?!?!

  6. camu
    Member
    Plugin Contributor

    Posted 3 years ago #

    Hi there,

    in order to avoid conflicts with other plugins/functions, I encapsulated my functions within a class. In order to use add_subscription you need to instantiate the class first (no need to include the file, I guess):

    $instance = new wp_subscribe_reloaded();
    $instance->add_subscription(parameters);

    Good work, though!
    Camu ;)

  7. mrarrow
    Member
    Posted 3 years ago #

    Well cover me in egg and flour and bake me for 14 minutes. It's worked!

    global $post;
    $email_to = get_post_meta($post->ID, 'Author Email', true);
    $_status = "Y";
    ....
    $instance = new wp_subscribe_reloaded();
    $instance->add_subscription($email_to, $_status, $post->ID);

    Now happily adding a new row to the subscribe_reloaded table! Also wrapped all my code in an IF statement to ensure a new notification message doesn't keep getting sent if a post is then republished/updated again - that would annoy submitters!

    Anyway, thanks for your assistance/comments! Seems to be fine now...

  8. camu
    Member
    Plugin Contributor

    Posted 3 years ago #

    Awesome :) A vote for my plugin would be a nice way to thank me :)

    Camu

  9. mrarrow
    Member
    Posted 3 years ago #

    I have voted! Thanks man!

  10. camu
    Member
    Plugin Contributor

    Posted 3 years ago #

    Really appreciated!

    Camu

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic