Created
July 28, 2016 17:45
-
-
Save danielkellyio/1375b74c7a8719929bcebf7e3e2b6550 to your computer and use it in GitHub Desktop.
Auto open a duplicated form for editing in gravity forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Open Duped to Edit | |
add_action( 'gform_after_duplicate_form', 'open_new_form', 10, 2 ); | |
function open_new_form($form_id, $new_id){ | |
$url = $_SERVER['SERVER_NAME'] . "/wp-admin/admin.php?page=gf_edit_forms&id=" . $new_id; | |
echo "<script>window.location = 'http://$url&duped=true'</script>"; | |
} | |
//Show Notification of Duped | |
add_action("gform_editor_js", 'notify_of_dupe'); | |
function notify_of_dupe(){ | |
if($_GET['duped'] === 'true'): ?> | |
<script> | |
(function($){ | |
var notification = '<div style="border-left-color:#46b450" class="updated_base gform_editor_status" id="after_update_dialog">' + | |
'<strong>Form duplicated successfully.</strong>' + | |
'</div>'; | |
$("#gf_form_toolbar").after(notification); | |
})(jQuery); | |
</script> | |
<?php endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment