If you want to hide the output of this shortcode from users who aren’t logged in, I’d make use of the is_user_logged_in() function built right into WordPress.
The issue you’ll run into, however, as Tom pointed out in the comments, is that you will need to check if users are logged in as part of the action that runs to favorite the post. Hiding the button doesn’t actually prevent users from using the action unless you protect the action itself as well.
Related Posts:
- Disable email notification after change of password
- __(): What if I have to pass in a variable?
- Run WP-CLI using PHP
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Plugin update error message
- How to build an API as a plugin
- How can I make my custom shortcode work in a Custom HTML Widget?
- PHP Deprecated: Non-static method should not be called statically
- Set a User as Author of all ‘New Posts’ posted
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Calling function from within functions.php returns unwanted value
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Check if a class exists within a method
- Escape special characters in image link
- Calling a plugin in theme development
- Unable to activate wordpress importer after installing it
- force customers to add only single item to card per purchase EDD [closed]
- How to get post URL in the_content filter?
- Write to / remove from default .htaccess file from plugin?
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- Programatically download a plugin
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- How to Use Parameters with a Do_Action Function Within PHP Tags
- Theme my Login plugin, how to update fields
- CSS from textarea in options page to frontend what to do
- How do I pass a post ID to the page URL?
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- add image crop function like in wp customizer
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- How to edit content before post update
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- Customize permalink wordpress category id
- Take input from form and pass it to function using a wp-plugin
- Self-serve ad system like Reddit’s for WordPress? [closed]
- Create a plugin from within WordPress
- Class variables not correct on page
- Load Javascript from Plugin in One Page Only?
- Call plugin with php function
- Setting Up PHP Workflow in WordPress
- What happens when WordPress memory limit is exceeded?
- How can I exclude a dynamic URL to show a popup created using ‘WordPress Popup’ plugin
- How do I add $_SESSION[”] to my wordpress page?
- output html on post or page from custom plugin [closed]
- WordPress: Add custom add_filter for custom functions
- How can i add simple code in only in posts by function.php
- Hide DIV if empty – Plugin Gallery
- Profile / benchmark wordpress on apache?
- Way to send multiple values for column to MySQL?
- How to change layout of shop page in wordpress? [closed]
- Retrieve Plugin Settings and insert into XML string
- WordPress Stats Plugin: Display Post Views [closed]
- Pagination not working
- exec-PHP shows output at bottom of page
- Can you echo PHP code from a variable?
- How to fix these PHP Warnings with the “Feed JSON” plug-in?
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Can I disable xml-rpc by setting it to false?
- Getting current user data with MySQL statement
- how to validate input field in wordpress generated with wpform plugin
- Conditional delete metadata does not works
- WordPress is redirecting me to homepage
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Redirect to a page while maintaining search query parameters without causing an infinite loop
- How to ignore fields if empty?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Moving a few select DB tables to a new WP instance
- Custom Field used to allow a Free Story; no longer works
- How to send new visitor to a splash page for only one time in wordpress?
- Cron job shedules replace?
- Create a form and have custom menu display based on user answers?
- How to get the total count of Favorite/Favorited authors
- Admin login substantially slower on production server
- Can i add custom code in Source in specific page, Header from function.php?
- Problem with conditional woocommerce custom checkout field
- GET web api method from a WordPress PHP script
- Adding link on title its in description but not in title see screenshots attached
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Editing Global Variables from Inside Functions
- Posting code inside the post instead of in the template file using shortcode
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- conditional tags for the output of a plugin
- Can’t insert files in other inputs
- How do I output user_registered time in my correct timezone?
- How to tweak a plugin without preventing it from updating
- Place max_execution_time in plugin [closed]
- Creating a press page for our project
- how to search through plugin in wordpress cimy-user-extra-fields?
- wordpress illegal string offset ‘parameter’ error
- Translate text for empty product
- Refresh server side rendered block in Gutenberg without changing attributes or its content
- Option value not getting updated until page refresh in WordPress
- Fatal error: Uncaught Error: Call to a member function fetch_array() on bool
- How to create a “Most Popular” & “Latest” TAB in WordPress
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class