Modifying user validation code from suggestions for forms

Home Forums Quform WordPress Modifying user validation code from suggestions for forms

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #13627
    fohlhorst
    Participant

    As per the guide on this site, I have added the following code to my functions.php to validate if a user is logged in before allowing them to fill out a form:

    function my_members_only_shortcode($atts, $content = null) { if (is_user_logged_in()) { $content = do_shortcode($content); } else { $content = ‘This content is for members only, please log in or register first.’; }

    return $content;
    } add_shortcode(‘members_only’, ‘my_members_only_shortcode’);****

    the above code has enabled me to use:

    [members_only][iphorm id=”1″ name=”Example form”][/members_only]

    on my posts to prevent users from accessing forms if they are not logged in

    However I would like the [Members_only] function / short code to either display a clickable hyperlink to the wp-login.php page, so a user can login and register with ease at that point in time –

    or, if there was a way for the [members_only] function to automatically place a widget in the “not logged in” area under the not logged in message – I would want that to be the social medial login widget, which I can call up in a post by using a short code created by a plugin – [do_widget “Social Login”] (thanks to the AMR Shortcode any widget plugin)

    I am no coder – but, I would think it should be easy to nest a function within a function to make it work that way or at the very least, turn the Content$ information into a hyperlink –

    Thanks in advance for any help!

    #13652
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #13663
    fohlhorst
    Participant

    Yes – consider this thread closed

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy