Forms for members only

This documentation page is for Quform version 1 and may not be applicable for Quform 2 click here to visit the documentation for Quform 2.

Forms for members only

There isn’t anything built in to the Quform plugin that you can use to make members only forms, however you can use a simple shortcode to do it. Add the following code to the wp-content/themes/YOUR_THEME/functions.php file (or create a plugin for it).

1
2
3
4
5
67
8
9
10
11
function my_members_only_shortcode($atts, $content = null)
{
    if (is_user_logged_in()) {
        $content = do_shortcode($content);
    } else {
        $content = '';    }
 
    return $content;
}
add_shortcode('members_only', 'my_members_only_shortcode');
function my_members_only_shortcode($atts, $content = null)
{
    if (is_user_logged_in()) {
        $content = do_shortcode($content);
    } else {
        $content = '';
    }

    return $content;
}
add_shortcode('members_only', 'my_members_only_shortcode');
  • On line 6 you can optionally add some text or HTML between the quotes to display a message if they are not logged in, by default nothing will be displayed.

In the page content editor you can now use the shortcode to make the form members only.

1
[members_only][iphorm id="1" name="Example form"][/members_only]
[members_only][iphorm id="1" name="Example form"][/members_only]

Forms for guests only

Add the following code to the wp-content/themes/YOUR_THEME/functions.php file (or create a plugin for it).

1
2
3
4
5
67
8
9
10
11
function my_guests_only_shortcode($atts, $content = null)
{
    if (!is_user_logged_in()) {
        $content = do_shortcode($content);
    } else {
        $content = '';    }
 
    return $content;
}
add_shortcode('guests_only', 'my_guests_only_shortcode');
function my_guests_only_shortcode($atts, $content = null)
{
    if (!is_user_logged_in()) {
        $content = do_shortcode($content);
    } else {
        $content = '';
    }

    return $content;
}
add_shortcode('guests_only', 'my_guests_only_shortcode');
  • On line 6 you can optionally add some text or HTML between the quotes to display a message if they are logged in, by default nothing will be displayed.

In the page content editor you can now use the shortcode to make the form members only.

1
[guests_only][iphorm id="1" name="Example form"][/guests_only]
[guests_only][iphorm id="1" name="Example form"][/guests_only]
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy