how to get the current page form ID use contact form block API?
-
Hello @Jordy Meow
Recently I have update the contact form block plugin to the latest version, that is a best contact form plugin(light weight, easy to use and flexible.), I have use it many years.
I know some simple PHP code, and I need to modify the form. After clicking the submit button, I need it to automatically jump to the position of the form, so I change the following code:
Path: wp-content/plugins/contact-form-block/classes/core.php:154
Before modification:
// Final data for this form
$data = array( 'success' => $success, 'error' => $error, 'form' => $form );
// If Success and URL Redirect, then redirect
$redirect_url = apply_filters( 'mcfb_redirect_url', get_option( 'mcfb_redirect_url', '' ), $success, $error, $form );
if ( $success && !empty( $redirect_url ) ) {
wp_safe_redirect( $redirect_url );
return;
}
// Prepare an ID associated with a transcient for the original page
$id = uniqid();
set_transient( "mcfb_{$id}", json_encode( $data ), 60 );
$url = esc_url( add_query_arg( 'mcfb_redirect', $id, $_SERVER["HTTP_REFERER"] ) );
wp_safe_redirect( $url );After modification:
// Final data for this form
$data = array( 'success' => $success, 'error' => $error, 'form' => $form );
// If Success and URL Redirect, then redirect
$redirect_url = apply_filters( 'mcfb_redirect_url', get_option( 'mcfb_redirect_url', '' ), $success, $error, $form );
if ( $success && !empty( $redirect_url ) ) {
$redirect_url = $redirect_url . '/#formID'; //my code, this section only work when the email send success.
wp_safe_redirect( $redirect_url );
return;
}
// Prepare an ID associated with a transcient for the original page
$id = uniqid();
set_transient( "mcfb_{$id}", json_encode( $data ), 60 );
$url = esc_url( add_query_arg( 'mcfb_redirect', $id, $_SERVER["HTTP_REFERER"] ) );
$url = $url . '/#formID'; //my code
wp_safe_redirect( $url );I would like to know if the contact form block plugin provides a method to obtain the current form ID.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.