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 can I get $id variable in widget’s form function?
- Shortcode producing headers already sent error
- Using add_filter() in Widgets
- Enabling shortcodes for custom fields
- How to use get_media_embedded_in_content function
- Shortcode with parameters inside parameters
- Programmatically Add Font-Awesome Icons to Category Widget
- 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
- Remove images from get_the_excerpt
- Dynamically Register Sidebars For Each Top Level Page
- Adding body class when post contains a specific shortcode
- Displaying Widgets
- Increment price for Woocommerce Minicart [closed]
- Missing argument 2 for a custom function widgets_init
- 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 first name of logged in user?
- WordPress shortcode attributes for database SELECT?
- Shortcode pagination not advancing
- 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
- Best practices regarding the creation of custom widgets?
- 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
- Passing variable as add_shortcode argument
- Add button to kitchen sink toggle
- Dashboard widget custom positioning?
- How do you Permanently Delete Sidebars
- Help With Creating Shortcode
- Shortcode parse error – wrong syntax
- Exclude category from shortcode
- How to use author meta in shortcode?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Output loop to function return?
- Woocommerce checkout field
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- dynamic site link for future migration in echo do_shortcode()
- Create a Woocommerce product widget with category filter
- Need a method to prevent WP from adding in between my shortcodes
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Add element to widgetpage
- “All posts” in the category widget
- How to create a shortcode out of a php function
- New checkbox in custom widget isn’t saving data
- Shortcode of a function
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Add a custom function to widget code
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- How to add if statement on WordPress shortcode output
- Passing function arguments via a shortcode
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- Enable accessibility mode in widget as default
- Function to function shortcode help [closed]
- Widget is displayed in two places
- Trying to change widgets h-tags
- I want to display the sku in the product pages of my EDD website
- Shortcode to insert default text and change one word throughout it?
- use add_action in a shortcode (gravity form – WordPress)
- Shortcode displaying outside the div [duplicate]
- Shortcode Initialization in a Custom Theme
- Shortcode with pagination advancing multiple queries
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- How to retrieve image IDs from shortcode content?
- Hide disclaimer from summary excerpts
- Function not receiving string from shortcode
- How to add widget in main menu
- Adding A New Widget to WordPress Disables the Existing Widgets
- Shortcode to eliminate and replace with
- Problem in outputting shortcode
- Problem in shortcode outputting content
- wp_nav_walker that interacts with widgets to setup mega menu
- WordPress Javascript Widget jQuery Dependency Issue
- How to display data from custom fields in my custom shortcode?
- Modify function Shortcode_atts
- Shortcode to output get_header not working
- restrict access to specific urls on a specific period of time
- using enqueue_script in a shortcode isn’t working
- Add title & subtitle to shortcodes
- Shortcodes not outputting in correct divs
- trouble with passing class method data to outside function
- Get term count on a category page
- How do grab the main loop, with conditions, and output via shortcodes
- Display function from functions.php in tag.php