Home › Forums › Quform WordPress › User Validation Before Form Launch
- This topic has 6 replies, 2 voices, and was last updated 9 years, 3 months ago by fohlhorst.
- AuthorPosts
- January 14, 2015 at 8:49 pm #13606fohlhorstParticipant
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?
January 14, 2015 at 11:09 pm #13608AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 15, 2015 at 3:23 am #13626fohlhorstParticipantThanks – 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’);January 15, 2015 at 11:54 am #13630AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 15, 2015 at 7:28 pm #13633fohlhorstParticipantAlly – 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?
January 18, 2015 at 3:41 pm #13651AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 18, 2015 at 9:20 pm #13662fohlhorstParticipantThis is perfect – thank you so much!
- AuthorPosts
- You must be logged in to reply to this topic.