Your problem is here:
'exclude' => '$user_id,1',
This will generate the string ‘$user_id,1’, it won’t insert the user ID into your string.
The reason for this is the difference between ‘$hello’ and “$hello” E.g.
$hello = 5;
echo '$hello'; // prints out $hello
echo "$hello"; // prints out 5
So using double rather than single quotes would fix your issue.
An even more reliable way
Use string concatenation to tie them together instead, e.g:
'exclude' => $user_id.',1',
The . operator joins two strings together, e.g.:
echo 'Hello there '.$firstname.', my name is '.$myname;
A more generic way
Use an array, and use implode to generate the string
$excluded_users = array();
$excluded_users[] = 1;
$excluded_users[] = $user_id;
// .. etc
'exclude' => implode( ',' , $excluded_users )
I recommend you read up on magic quotes in basic PHP and string handling
Related Posts:
- Woocommerce – adding variations to variations [closed]
- How to export comments in WordPress?
- Overriding Plugin Template Files with Child Theme
- Can YOAST SEO fields be removed from custom post type [duplicate]
- What causes the “Are you sure you want to do this?” error with plugins?
- Creating Unique Post URLs for A/B Testing… Is this even possible?
- Suggest a plugin for up/down voting posts [closed]
- Can’t install local plugin (zip) with wp-cli [closed]
- scheduled event not getting executed
- How can I limit functionality in one version of a plugin?
- WordPress A-Z Navigation
- __autoload in a plugin throws an error in WP – not able to locate translation_entry.class.php
- Any way to use a custom Parameter for youtube embed without using an iframe?
- How do I add a template to a theme using a plugin?
- How to Add TinyMCE’s plugin in wordpress?
- How to check if I am displaying categories on a Woocommerce page? [closed]
- Stop the form of beign submitted on “Save changes” custom option page
- What user roles should have wp_unique_post_slug_is_bad_flat_slug filter applied?
- Is there a way to make a pure vanila page of just HTML/CSS/JS
- Appery.io and WordPress
- Simple ajax call not working in wordpress plugin
- How to save post change url youtube link?
- How make a php script run only with wp-cron
- __callStatic method handler passed to add_action causes bug in PHP
- Multiple instances of nivo slider plugin
- How to use wordpress $polylang->model->set_post_language in custom php code?
- Plugin-generated pages use Not Found or Pages Archive templates?
- Most efficient way to use classes to create admin pages using Settings API
- CMB2 toolkit: Compare 2 Dates and validate the Time
- Where does the cookie mo_page_views_counter come from?
- Save custom attributes of product in woocommerce
- Add padding while generating thumbnail
- How to add tags in Submenu page or Menu page
- Using TinyMCE in plugin?
- How to display taxonomy images with wp_list_categories?
- How to use is_single and get_post_type within a plugin?
- How do I get a post author’s image/avatar via RSS from another blog?
- Maintaining plugin addons while upgrading
- what is name of this plugin used for photo gallery page [closed]
- Why can’t I call a (member) function from within a foreach?
- flush_rewrite_rules() not working with update_option_{$option}
- Vulnerability Concern From the Plugin or From Not Updating the Plugin?
- PHP if statement with German umlauts [closed]
- How to ignore extra whitespaces in translation functions like _e?
- Can backlinks to my site increase my chances of plugin rejection
- Hide a certain category name from Related Posts
- Custom Font Complications (WordPress) [closed]
- How does translation (gettext) work for translating config file of plugin?
- wp_logout_url($redirect); is not working in wordpress
- How do I determine if the user who registered is not spam?
- display unique post per category
- How to display a widget on a page with no theme?
- Prevent plug-in scripts on a specific template?
- using wp_footer hook in a plugin
- I’m looking for a visual composer / builder plugin that supports RTL
- Which is a better practice when writing shortcodes: pack lots of configuration parameters or just give an id?
- Plugin prevents code from working
- Determining Whether Automatic Upgrade will Fail?
- I’m having several WP issues, especially with missing images
- I’m looking for a plugin to execute a specific task a certain time
- Show an admin menu item in Editor role
- Want to create custom design of progress indicator in wpforms
- Add Plugin broken after removing Booster for Woocommerce
- WP_CONTENT_DIR disables plugin directory
- WordPress Custom Hook with Class method
- How create bulk website with amount, total, and checkout fields?
- Open_basedir errors – But setting basedir to none redults in 502 Bad Gateway
- Ensure WordPress Theme Uninstalls Completely
- add a hook of Woocommerce to a plugin but it only shows and doesn’t function properly
- Change language in SiteOrigin Widgets
- Image path in childs theme
- one url for all pages
- Using foreach loop for `$instance` of form and update array widget iteration
- how to insert thousands of posts faster?
- Redeclare a plugins function/class in my theme?
- Passing data from a page to an external link
- Send email when a user registers Rest api
- Coupon Codes for product discount combined with conditional free shipping
- Avoid enormous network payloads
- There was a problem uploading the cover image in buddypress, while uploading profile image?
- How to create a custom control in customizer
- Sanitize AROUND shortcode
- Primary Menu doesn’t show because of w3 cache
- Create shared actions for admin and users with plugin bolierplate
- Plugin Screenshots not showing
- How to Insert images in WordPress using code
- Wp Ecommerce Reposition Product Page Product Thumbnail Image
- It possible to implement an adhoc php web application with wordpress?
- Jetpack Comments Change Placeholder Text
- shortcode which is introduced into entry the blog, and appears in side bar
- How to test a WordPress plugin on a single post?
- Plugin and javascript placement
- Disable plugin function
- Modify plugin and submit to directory
- Sort Reviews/Ratings by date on Woocommerce
- How to validate password length in wordpress
- How to add a text in the checkout page woocomerce?
- How to filter plugin search results in wp-admin plugin search page
- How can I disable a plugin in Health Check mode if there’s a critical error?
- Automatically create WooCommerce products page by just uploading the images [closed]