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
- Auto gallery from folder contents
- Secure Pages Best Practice
- Conditional hook based on the core function that is calling it
- add_shortcode() not working inside of function
- do_action and add_action on two different installed plugins won’t work
- How to change the hover content of a specific menu item on WordPress?
- Using a post-signup hook to get user details
- how to search users by ajax live search
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Send push when new post is published in a certain category
- creating html reusable blocks via shortcodes
- Remove unwanted elements for a wp_nav_menu
- How do I update a field of a meta box?
- Asynchronously render shortcodes in TinyMCE visual editor
- 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
- Shortcode returning localized HTML part
- template_redirect or admin-ajax.php?
- WordPress custom taxonomy check box to dropdown
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Force HTTPS 301 redirect with hook
- Hide shortcodes “code” when using the “editor” the same as wordpress do with “gallery”
- I have 2 plugins using the same wp_login action hook and one is not working
- WordPress function get_the_terms() returns ‘Invalid taxonomy’ error
- Display gallery on bottom after content
- Enumerating shortcode attributes in JavaScript
- Add a new confirmation page before saving
- Checking for existence of a page by title?
- how to get context information inside my funcion
- Wrap text around shortcode
- wp_nonce_field displaying twice
- WordPress class, using add_action to call member function does not work
- Redirect to another page using contact form 7? [closed]
- use of do_action() without any functions attached
- How dynamic action login_form_{action} is working
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- What happens when two or more plugins use the same hook?
- How to handle shortcodes through plugin
- wp_get_post_terms Order by not working
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- How to get all queries’s results after they have executed?
- Function/Class to list categories with checkboxes
- wp_get_theme Warning: Illegal offset type
- Plugin uninstall function is not working
- Bug: Post needs to be updated twice when adding action for save_post hook
- Using a custom shortcode from within the template of a shortcode plugin
- When echoing my own shortcode, it keeps adding a 1 at the end of my blogpost
- Why wp_die() doesn’t work with wp_redirect but exit() works
- flush rewrite rules after plugin update?
- When does save_post hook fire on post save/update
- Plugin does not add action
- Remove an action by extending class and replacing it
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Add child pages to submenu automatically
- Print Dashboard submenu name and filename
- Autogenerate a Table of Contents
- After plugin activation hook
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- How to replace default comments with custom HTML?
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- How can I create a custom plugin that allows anonymous users to signup without registering?
- hook filter after the_content on a specific page
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Automating the process of shortcode generation in a plugin – how is it done?
- Bind a function with its own argument to show something dynamically after every content
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- Why enqueue styles on hook?
- How to Add a Custom Size for Thumbnails for WP – Gallery
- What’s the hook for filtering every texts of site?
- Create Widget or Enable Shortcodes in Sidebar
- WordPress multisite,use same cookies across all website?
- Apply styles to blockquote element with the WYSIWYG editor
- Hook add_attachment error
- Associate multiple email addresses with the same user account, so they can log in with either
- shortcode executed in the page editor
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Run command “composer install” when activating wordpress plugin
- Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all
- unregister_setting() vs delete_option() for plugin update