Have you tried:
function my_members_only_shortcode($atts, $content = null) {
if ( !is_user_logged_in() ) {
$content="<p>This content is for members only. Please log in or register first.</p>" . do_shortcode('[do_widget "Social Login" ]');
}
return $content;
}
That should replace the content with your message and special short code content only if the user is not logged in.
The short code looks funky to me … so correct it if I have it wrong, but the idea is to just replace the content and use do_shortcode(‘[your_shortcode_here]’) to append the form to your custom message… and leave the content alone if they are logged in.
Related Posts:
- How can I make a widget shortcode to control all the widgets?
- WordPress Shortcode function display outside of widget
- Solution to render Shortcodes in Admin Editor
- Use AJAX in shortcode
- Can the new 4.8v text widget visual editor be removed?
- Include PHP file in Content using [shortcode]
- How to influence the information displayed on widget inside wp-admin
- How to add css class to cloud tag anchors?
- How can I get $id variable in widget’s form function?
- Shortcode producing headers already sent error
- How to add attributes to a shortcode
- How to display random users with avatars
- Using add_filter() in Widgets
- Enabling shortcodes for custom fields
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- How to use get_media_embedded_in_content function
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Shortcode with parameters inside parameters
- remove the wrapping of text widget or
- remove from text-widget
- Creating a table from shortcode avoiding wpautop for each row
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Stripping shortcode from custom excerpt function
- Programmatically Add Font-Awesome Icons to Category Widget
- how to create shortcode in wordpress
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Display random text from a file with the WP built-in AJAX API
- Authors details such as social media links, emails etc → Is this Meta or something else?
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- Dynamically Register Sidebars For Each Top Level Page
- Shortcode with custom content attribute?
- Customising widget titles/headings in WP 5.8
- Problem with extract() with custom shortcode
- Shortcode to insert menu in page body?
- Using locate-template & shortcodes doesn’t appear to work
- Widgets Section not displaying in theme customizer
- Displaying a random user with a shortcode
- Passing HTML in WordPress Shortcode arguments
- Adding body class when post contains a specific shortcode
- Displaying Widgets
- What is the most efficient method for loading widgets in functions.php
- Function to show only first instance of shortcode
- Display a text message if the shortcode is found?
- WordPress menu deletes when trying to add a hook
- Ajaxing function in widget class
- Increment price for Woocommerce Minicart [closed]
- creating shortcode to pull json array
- Custom Shortcode, functions PHP WP_Query loop
- Missing argument 2 for a custom function widgets_init
- Pass Shortcode Attribute to footer Script
- Super simple shortcode not working
- Detect Safari desktop browser and include the detection in a shortcode
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- Display gallery on top before content
- List child pages of specific page using shortcode
- How to extract the variables out from “add_shortcode” function?
- Display first name of logged in user?
- Adding widget to dashboard with wp_dashboard_setup not working
- How to get specified parent page title in my function
- Possible to display shortcode based on the category?
- WordPress shortcode attributes for database SELECT?
- Shortcode pagination not advancing
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- How to insert custom widget in custom sidebar in theme activation?
- Having issues with a foreach inside of a shortcode with ACF gallery
- Right way to update widget on dynamic new input field
- Shortcode inserts paragraphs before and after executing shortcode
- Passing values from a widget to a function within a plugin
- Override widget in function WordPress
- Display post shortcode content in the sidebar?
- How to get the index number of the posts?
- Best practices regarding the creation of custom widgets?
- Using shortcode content with nested shortcode
- Custom shortcodes not inserting into visual composer columns
- How to filter $content in shortcode function
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Replace a menu with widget or a custom template file programmatically
- Setting youtube size in functions.php
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- Custom taxonomy widget in admin area
- Display gallery on bottom after content
- Add button to kitchen sink toggle
- Dashboard widget custom positioning?
- How do you Permanently Delete Sidebars
- Excerpts are not displayed by a shortcode on category pages
- Get rid of the widget Item Class=”widget-item”
- check if the user is owner of current page
- shortcode help require
- Optimizing a WordPress site
- Help With Creating Shortcode
- Custom Sidebar only on single post
- Use html inside shortcode function
- Shotcode argument issues
- Shortcode parse error – wrong syntax
- Exclude category from shortcode
- wp_nonce_field is breaking form for reasons unknown