i have multi-page forms. i want users passed first page adn see second page automaticly if they are logged in. is it possible with some custom code or hook.
Thanks.
i have multi-page forms. i want users passed first page adn see second page automaticly if they are logged in. is it possible with some custom code or hook.
Thanks.
Try the following. It is not very pretty, but I think it will do the job for you. Make sure you replace 134 with your actual form ID
//NOTE: Replace 134 with your actual form ID
add_action("gform_pre_render_134", "skip_first_page");
function skip_first_page($form){
if(is_user_logged_in()){
GFFormDisplay::$submission[$form["id"]] = array("page_number" => 2);
wp_enqueue_script("jquery");
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".gform_previous_button").hide();
});
</script>
<?php
}
return $form;
}
This is it.
But one question. If i want to use it for multiple forms. Is there way to do this. Something like coma seperate form id numbers or something else ...(sorry i am not a coder )
And one more thing with this code it passes first page it goes to second page but when i click to next for going to third page i does not go to third page. it stays at the second page Also when i click next it shows previous buton. is there way to fix this?
Thank you very much Alex.
Here we go. Have fun.
add_action("gform_pre_render", "skip_first_page");
function skip_first_page($form){
//NOTE: Replace the form IDs below (i.e. "134", "135", "136") with your actual form IDs
if(in_array($form["id"], array("134", "135", "136"))){
if(is_user_logged_in()){
if(!isset(GFFormDisplay::$submission[$form["id"]])){
GFFormDisplay::$submission[$form["id"]] = array("page_number" => 2);
}
if(GFFormDisplay::$submission[$form["id"]]["page_number"] == 2){
wp_enqueue_script("jquery");
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".gform_previous_button").hide();
});
</script>
<?php
}
}
}
return $form;
}
wonderful :)
Thanks Alex