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"]