WordPress.org

Ready to get started?Download WordPress

Forums

Simple Basic Contact Form
[resolved] Form's action attribute automatically set to be URL of most recently-posted post (5 posts)

  1. snthr
    Member
    Posted 1 year ago #

    Hi, I’m using this plugin on this page. If you view source, you can see that the URL assigned to the form’s action attribute is the URL of the most recently-posted blog post, instead of being the front page of the site. Is there any way to set this to be the front page, or alternatively to redirect users of the form back to the front page after they fill out the form?

    I’m hoping I haven’t missed something obvious here – I’m a little stumped!

    Any help would be great. Thanks.

    http://wordpress.org/plugins/simple-basic-contact-form/

  2. Jeff Starr
    Member
    Plugin Author

    Posted 9 months ago #

    Redirecting to the home page or some other fixed URL is straightforward, just add either of these lines:

    wp_redirect(home_url()); exit;
    wp_redirect('http://example.com/somewhere/'); exit;

    ..add them just beneath either this line:

    if ($carbon == 1) mail($email, $topic, $fullmsg, $headers);

    ..or this line (depending on which method you are using):

    if ($carbon == 1) wp_mail($email, $topic, $fullmsg, $headers);

    Redirecting to the latest post should be do-able using similar logic and the wp_get_recent_posts function:

    http://codex.wordpress.org/Function_Reference/wp_get_recent_posts

  3. snthr
    Member
    Posted 9 months ago #

    Hi Jeff,

    Thanks for the reply. Just a point: should I edit this in the plugin files themselves? That is, below the point where you say “NO EDITING REQUIRED - PLEASE SET PREFERENCES IN THE WP ADMIN!”

    What happens if I update the plugin? Won’t it overwrite my edits and re-create the original problem?

    Thanks.

  4. Jeff Starr
    Member
    Plugin Author

    Posted 9 months ago #

    Yes that is correct. Definitely don't edit the plugin files if you are not comfortable doing so. Also, I'm working on a "Pro" version of the plugin that will provide further options for redirecting users after submissions, errors, etc.

  5. snthr
    Member
    Posted 9 months ago #

    Ok, thanks for the clarification.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic