Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect after duplicate #2139

Open
rafaehlers opened this issue Sep 14, 2024 · 0 comments
Open

Redirect after duplicate #2139

rafaehlers opened this issue Sep 14, 2024 · 0 comments
Assignees

Comments

@rafaehlers
Copy link
Contributor

rafaehlers commented Sep 14, 2024

Context

It seems like there are plenty of folks who want this functionality: https://secure.helpscout.net/search/?query=tag%3Aduplicate%20entries%20redirect

I know we have the gravityview/duplicate-entry/duplicated hook but perhaps it's time to implement an UI for that?

The idea is to mimic the functionality already present in the Delete tab, but for duplicating entries. I think we can even use the same tab to avoid creating a new one since the Delete tab only has two items.

image

Code suggestion:

add_action( 'gravityview/duplicate-entry/duplicated', 'gk_run_stuff_after_duplication', 10, 2 );
function gk_run_stuff_after_duplication( $duplicated_entry, $entry ) {
    $form_id = $duplicated_entry['form_id'];
    
    $run_on_forms = [157]; // The IDs of the Forms you'd like to affect.

    if ( ! in_array( $form_id, $run_on_forms ) ) {
        return;
    }

    // Redirect to the desired URL.
    $url = 'http://www.website.com/page/';
    wp_redirect( $url );
    exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants