Home › Forums › Quform WordPress › Modifying user validation code from suggestions for forms
- This topic has 2 replies, 2 voices, and was last updated 9 years, 3 months ago by fohlhorst.
- AuthorPosts
- January 15, 2015 at 3:48 am #13627fohlhorstParticipant
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!
January 18, 2015 at 3:45 pm #13652AllySupport 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:22 pm #13663fohlhorstParticipantYes – consider this thread closed
- AuthorPosts
- You must be logged in to reply to this topic.