• Resolved snthr

    (@snthr)


    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.

    https://www.ads-software.com/plugins/simple-basic-contact-form/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Jeff Starr

    (@specialk)

    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('https://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:

    https://codex.www.ads-software.com/Function_Reference/wp_get_recent_posts

    Thread Starter snthr

    (@snthr)

    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.

    Jeff Starr

    (@specialk)

    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.

    Thread Starter snthr

    (@snthr)

    Ok, thanks for the clarification.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Form's action attribute automatically set to be URL of most recently-posted post’ is closed to new replies.