I’m trying to modify the below code snippet / function hook to disable registration if the user is logged in.

<?php
add_filter("gform_disable_registration", "disable_registration", 10, 4);
function disable_registration($is_disabled, $form, $entry, $fulfilled){
//check form id and if not the form being checked status passed in to function
if ($form["id"] != 160)
    return $is_disabled;
//check submitted values to decide if registration should be stopped
if ($entry["4"] == "No" && $entry["5"] == "No") {
    //disable registration
    return true;
}
else{
    return false;
}   
}
?>

I’ve tried the following to no avail:

add_filter("gform_disable_registration", "disable_registration", 10, 4);
function disable_registration($is_disabled, $form, $fulfilled){
//check form id and if not the form being checked status passed in to function
if ($form["id"] != 2)           
return $is_disabled;
 //check user login to decide if registration should be stopped
   if( ! is_user_logged_in() ) {
return true;        
}
else {
return false;
}  
}

Hoping I can get this to work! Thank you.

Read more here: Gravity Forms User Registration - disable for logged-in users.


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: