This code should work in your functions.php
add_shortcode('gallery', 'custom_gallery_function');
function custom_gallery_function($atts) {
$user = wp_get_current_user();
// if current user isn't admin, add posts to be hidden to exclude
if(!in_array('administrator', $user->roles))
$atts['exclude'] = $atts['exclude'] . ',' . $atts['hide'];
// call the wordpress shortcode function
return gallery_shortcode($atts);
}
Related Posts:
- Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
- Shortcodes, output buffering, and WordPress functions
- Dynamically Override Fancy Title
- Get returned variable from a function to add_shortcode function
- What function to hook for changes made in status and visibility of a post
- Is it possible to delay execution of shortcode output callback?
- WordPress after content Hook & external template part
- get_current_screen() return null
- correct way to call javascript into hook function
- Call to undefined function is_home() or any conditional tags
- How to output functions from plugin inside theme
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Function not working on any file other than the main plugin file
- Template file structure , wordpress hook for altering the template
- WordPress simple ‘Hello World’ plugin – problems
- get_term_by() returning null on plugin
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Which hook should be used to add an action containing a redirect?
- function deactivate_plugins does not exist
- Understanding WordPress functions’ naming conventions
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Are shortcodes case-sensitive?
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- WordPress scheduled task is called but not executed
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- When is it appropriate to put functions on page template vs. functions.php?
- How to modify post content before writing to database?
- How can i list current author’s categories?
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- stray elements
- Pass javascript result to shortcode executer function
- Is it possible to create an action hook using do_action() within add_action()?
- What is the Difference between directly call a function and call a function using add_action?
- Call to undefined function get_blog_option()
- Undefined function wp_set_password
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Best Practices for Creating and Handling Forms with Plugins?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Woocommerce – Hide a Column in Cart Table
- Placement of Code in Plugin for hooking `save_post`
- How can I add a CSS rule to edit.php?
- Making Quote Plugin more efficient
- Namespaced action and filter tags
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- What is the best way to embed an JS App in a WordPress Page?
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- Trying to understand order and frequency of action hooks firing
- Where can i find wordpress auto update code flows?
- Auto gallery from folder contents
- Secure Pages Best Practice
- how to search users by ajax live search
- Remove unwanted elements for a wp_nav_menu
- Custom login doesn’t work properly
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- Run Shortcode of post’s custom field in functions.php / Plugin
- How to add user details to different tables immediately after user registration
- WordPress custom taxonomy check box to dropdown
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- wp_get_post_terms Order by not working
- Function/Class to list categories with checkboxes
- Using a custom shortcode from within the template of a shortcode plugin
- Why wp_die() doesn’t work with wp_redirect but exit() works
- Remove an action by extending class and replacing it
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- How to Add a Custom Size for Thumbnails for WP – Gallery
- Create Widget or Enable Shortcodes in Sidebar
- shortcode executed in the page editor
- How to change WooCommerce loop product title HTML output in single product page and archive page
- How to make my shortcode load scripts and styles, from within the plugin?
- Restrict certain actions to plugin-specific admin menu pages only
- Adding tables to dashboard pages programmatically?
- Custom Settings Plugin Save foreach checkboxes
- How to update global variables in plugin activation callback?
- function add custom fields to media gallery
- Make visible page only in the trash
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Hook for validating and rejecting frontend image upload
- How do I show the HTML descrption in wordpress photo gallery for my individual gallery pages?
- WordPress plugin how to run function when button is clicked
- Pass javascript result to shortcode executer function
- remove different admin menu for specific users
- Shortcode from a plugin not working
- plugin modal/popup integration best practice
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- WordPress permalink setting
- Dynamic banner for use on external sites
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- How can i call from custom fields to the category editor?
- Get user logged in status from within a plugin. $current_user not defined
- Loop output for custom plugin [solution found]
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- How to Pass ID through Short Code
- Send Webhook when post-status is publish or trash
- Using “add_image_size” to register custom image sizes inside plugins not working
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- Ninja Forms: Front-End Forms, Post ID?
- Execute callback after REST API request completes + Response is sent