User Validation Before Form Launch

Home Forums Quform WordPress User Validation Before Form Launch

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

    Is there any way to check for WordPress function is_user_logged_in() and redirect to the wp-login.php if the user is not logged in / registered and then come back to the form after the user logs in?

    #13608
    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.

    #13626
    fohlhorst
    Participant

    Thanks – I did what was in the guide and that does effectively prevent the form from showing if the user is not logged in – what I would really like to do is offer a way to login / register as part of the logic – but, I am no coder!

    so is there some way to put a hyperlink into the text that is shown from the function: code below like making the $content look like this? $content = ‘This content is for members only, please log in or register first. by clicking http:\\www.website.com\login.php’;

    Simply put, I want the text that is stored in the content variable to be a hyperlink to a login page

    or, better yet if I can make the logic place a widget on the post for social login

    Below is the original code that has been added to the functions.php for the theme – so, I would want to modify that to either have a plugin show (Social Login widget) or at the very least, offer a hyperlink to the wp-login.php

    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’);

    #13630
    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.

    #13633
    fohlhorst
    Participant

    Ally – this works great!

    $content = ‘This content is for members only, please log in or register first.’;

    one question though, can the hyperlink be setup to return to the calling page using something like a &redirect_to= command, once the user logs in?

    #13651
    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.

    #13662
    fohlhorst
    Participant

    This is perfect – thank you so much!

Viewing 7 posts - 1 through 7 (of 7 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