• Resolved tripeld

    (@tripeld)


    hello,

    I’m struggeling with the following.
    I made a specific subscription form which saves the data in a db (not in wordpress db).

    I made the form in a wordpress page but the action is a link to a stand-alone php file in the same directory. (so not related to wordpress)
    It works, and is functional but I
    suppose this isn’t really the way to do it :-),
    Could you get me started how to do it properly?

    Second part:
    Now I want to send an email with attachment when the subscription is finished. Therefore I thought about using PHPMailer but I am afraid to have troubles with wordpress if I install other scripts?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • It depends on what exactly the form does.

    For example: You might want to look at the way you want that info to live. I’d suggest trying some plugins such as WPForms that’ll allow you to create forms and save the data for later consumption trough the WP Admin Panel.

    Moderator bcworkz

    (@bcworkz)

    If you want to use form data within WP, you are limited in where you can submit data. You could submit to a page that uses a custom template to process the data. You can use Ajax methods through requests to /wp-admin/admin-ajax.php. You can make GET or POST requests to /wp-admin/admin-post.php. That’s it, but they should be more than adequate.

    Once the WP environment in initialized, you can use wp_mail() to send out email messages. I believe it uses PHPMailer if it’s available. In any case it works out the best transport and uses it. wp_mail() accepts arguments for attachments.

    Adding server modules should not affect WP, nor should other apps or scripts utilizing other namespaces.

    Thread Starter tripeld

    (@tripeld)

    I must say, i am actualy using a custom page, but it’s not a template in WP. It consists of only PHP Code, so I don’t understand how to use that as a template?

    the reason why i didn’t use a plugin: it’s a subscription form for children, in which we also ask the name of the parents.

    I check how many children they have and then execute that many query’s:
    child 1 – parent name – parent phone
    child 2 – parent name – parent phone
    child 3 – parent name – parent phone

    It’s only to have a list of subscriptions, no extra data needed…
    With plugins, I couldn’t alter the sql query’s and they had to put the same info X times….

    Moderator bcworkz

    (@bcworkz)

    If you don’t have any need of WP resources, then that’s fine. I was merely pointing out that there are alternatives, as much for anyone else reading as for you. There’s no need for a separate DB, or even a custom table for that matter, it could all be managed within WP. But there’s nothing wrong with what you have if it works for you.

    FWIW, to make a custom page template, you merely need to include a particular comment at the top of the PHP code page and place the file in a child theme’s folder. Then all of the WP resources are available to that template.

    Thread Starter tripeld

    (@tripeld)

    hello,

    ok, thanks. I must say, i did indeed use it as a template, and merged my script and success page together. And indeed then i used wp_mail te send the email with attachment.

    Thanks for your help!

    Moderator bcworkz

    (@bcworkz)

    You’re welcome! Gotta like anyone who tries new things even though what they had works just fine ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘add custom subscription form in wordpress’ is closed to new replies.