Wrong approach. $print_submenu_navigation
will be filled in local scope when function is called with arguments, it’s not a matter of global variables.
You want something like this when function is called (not defined):
load_view( 'name', array(), current_user_can('administrator') ) {
Alternatively you can add your snippet inside the function, then input value for $print_submenu_navigation
will overwritten with result of your check.
And it’s shorter to write it like this, function returns boolean:
$print_submenu_navigation = current_user_can('administrator');
Related Posts:
- How to get variables from fucntion.php to my plugin files
- Passing stored variables to add_filter
- Best collection of code for your 'functions.php' file [closed]
- Between functions.php (theme), widgets, and plugins, which is loaded first?
- Where do I put the code snippets I found here or somewhere else on the web?
- Manually set global $post vars with an ID, in order to use template tags
- Disable plugin / plugin action via theme
- How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?
- How do I replace a function, declared inside a plugin’s class, in functions.php?
- How to not allow users to create new tags, but allow to them to use existing ones
- How to export comments in WordPress?
- How to include a plugin’s php file to another plugin functions file [duplicate]
- How can I call a function from one plugin within another plugin?
- Shared functionality in plugins and themes
- Gutenberg disallow certain custom blocks but keep all core blocks?
- Remote upload file to server B
- Publish author posts only with editor approval?
- Replacing Icons in the Dashboard
- How to remove WPML Generator Meta Tag by theme’s functions.php (override plugin function)? [closed]
- Plugin update error message
- Limit access to posts/pages by user roles
- Using functions from a plugin in your theme
- Prevent publishing the post before setting a featured image?
- Keep one user logged for a year?
- Remove Google Fonts Which Are (Probably) Added By Plugins
- Customizing subject in comment notification e-mails
- if plugin is active? check if plugin is enabled or not?
- Common functionality between my own plugins
- WP showing “warning: call_user_func_array()”, What to do?
- Need to create a Theme demo site that features multiple themes
- Adding a text domain to every __(), _e() and __n() gettext call without a plan to create own translations
- Define Function in functions.php or plugin and call in theme loop
- Autogenerate wordpress shortcodes using array?
- How to Loop Plugin Option Field Set?
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- Declare a function before plugin does on the theme functions.php file
- How to handel multiple checkbox field in the admin settings page with Settings API
- Why does including a file in theme’s functions.php not work?
- wp_insert_user – how to send verification email before logging in
- How to override a theme function (within a class) using a plugin
- Editor access to plugin settings
- WooCommerce create new product and add to cart on form submit
- Seeking clarification on page request life-cycle
- Generate Advanced Custom Fields box in custom admin menu page
- How to assign user a role if none is present when logging in
- Is the WordPress HTTPS Plugin Still Safe To Use? [closed]
- Saving Plugin settings to the database
- Set a User as Author of all ‘New Posts’ posted
- Shortcode display outside the div
- Post source link plugin – small modification
- Adding New Role
- Change destination author link
- How to turn off email you receive when registered?
- Removing user contact methods works from functions.php but not from a plugin
- Execute a function using ajax
- Shortcode under a Shortcode Multiple times Possible?
- Custom Widget outputs the input but doesn’t save anything inside the textarea
- How do you auto-activate plugins from child themes
- How to call a plugin function in footer.php
- Add Top-Level Menu that opens URL
- How to load plugin before the wordpress jquery?
- How to remove action from plugin?
- While Using Static Pages, How Can I Get /blog into the URL of Each Post?
- Use functionality of 2 wordpress plugins
- What is the function to get plugin base url in multisite?
- Code in theme functions.php faster than with a plugin?
- Fatal error: Class not found in
- Disabling post images for not logged in users
- What’s the point of using WordPress’s built in admin-ajax.php?
- wordpress custom login successful redirect hook
- How can i change an image’s author?
- Converting a simple plugin to be placed inside of functions.php
- WordPress ajax call for not logged in users, doesn’t work
- Extend Elementor Archive Posts widget with a custom skin in order to show multiple badges
- HELP: Integrating WP with raw PHP code once published button is hit
- Over write plugin templates
- How to find out what blocks are added by a plugin
- Display All Non-Used Plugins
- Override plugin functions in functions.php
- Override the core function locate_template
- How to redirect Old Post URL to new Post and keep Old post Comments?
- Can wp_script_is used in pluginA check if a script is being enqueued/registered from pluginB?
- Using has_filter with a class based plugin to check whether the plugin is active or not
- Modifying Footnote Plugin for Descriptive Title Attributes
- I would like to use create a function in my custom plugin to tell WP to use a different header
- New Plugin: Post update pushes a copy as a revision
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- Showing Co-Authors on post page
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- bulk change of image setting “link to” to “link to: image url “
- Placement of Code in Plugin for hooking `save_post`
- jQuery Plugin to use WordPress functions in AJAX request
- Using plugin functionality in external php script not working
- ajax front-end increment views on click
- Display a text message if the field is not found and not if found
- Trying to count the total number of paragraphs inside a blog article
- greatest() function returns undefined property
- Limit the number of plugins that can be installed in a WordPress installation
- Debugging Technique Question re: functions.php
- Add get_option to jquery