I found the problem and also fixed a bug in the regex.
Final code:
'meta_query' => array(
array(
'key' => 'my_meta_field',
'value' => "(^|\n|\r\n)99999($|\n|\r\n)",
'compare' => 'REGEXP',
),
),
The problem here was WordPress was adding extra backslashes on the special characters. By wrapping the expression in double quotes, this problem was solved.
Also added end of string/new line capturing on the tail end of the target value.
Related Posts:
- What do ++ and *+ mean?
- Correct regex for wp_embed_register_handler
- Add extra field to users
- Display user’s total comment count outside The Loop
- What is the most efficient way to search users by their display name?
- Network installation giving errors when viewing or adding a user
- Showing user ID on user main page from screen options
- Getting the Current User
- How do I hide specific user profile fields?
- Authenticating to WordPress, using my own authentication two-factor system
- Modern Tribe Calendar wp-query with meta query not working at all
- sql query to put quotes around numbers in img tag
- How can I default to all WordPress roles when parameter is not included in shortcode?
- there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?
- How to display custom field on homepage
- Delete option value from array using update_option()
- Can an array be used as a meta_query value?
- List of posts by day of the week
- get_users(…) only returns one user
- List User order by ID in Descending order (Backend)
- Get all user meta by meta key instead of ID
- How to get a list of all possible values of a specific user meta key?
- WP_Query Check if post has one or more attached medias
- Custom user login page by creating a plugin
- Applying A Category to Existing Posts Where Page Title Matches Regex
- user_profile_update_errors hook not executing
- Get users that likes the post
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- add_cap not working
- Custom query, checking values of multiple meta keys
- wordpress archive a user
- Call to undefined function get_userdata() in plugin
- how to remove colon and white space in a string by php
- Get URL from shortcode tag
- Is it possible to retrieve all posts with a certain value for metadata?
- Change CSS based on is_user_logged_in
- Grouping posts by a custom meta value
- Preg_Match(): compilation failed unknown property name
- How do you create two separate Register pages?
- How to add no follow to specific links?
- php preg_match with multiple patterns
- Undefined offset: 0-wp-includes/meta.php:488 -Melding
- Passing an array into WP_Query as a variable
- WordPress meta_query >= &
- Get the users that my following users are following
- create front-end users post list by specific category
- How do I remove duplicate users from two merged WP_User_Query objects?
- ‘pre_user_query’ interfering with user export
- php return username of currently viewed author profile
- How can I call a specific file (via php) by referencing the logged-in username?
- Redirect to current user page upon link click
- Use of antispambot with $curauth->email
- Uses for function: wp_update_user
- Display additional user fields
- Generate a QR code when creating a new WordPress user
- Change wordpress’ database data using ajax – how to get current user id?
- Allow a user or role to view drafts and previews, but not other admin privileges?
- Storing huge number of users in wordpress
- wp_Query with mutuplea values returns all posts
- How to block specific user id in custom login form?
- Get current user id in function php
- Usermeta data unserialize, extract and display in table in WordPress
- how can I call a function when time expire
- Hide Approved status for certain users in users list
- Uploading/integrating custom user registration page
- Export WordPress User Meta to CSV/Excel
- Page template not working when logged out
- Display current user metadata on WordPress page
- Help hooking into user_register
- Meta query not showing result properly
- Add another role to a user when they click a button?
- WordPress add_rewrite_rule
- wordpress more than one ajax request at the same time issue
- Filter loop by ‘price’ with meta_query
- (Who to follow) Twitter widget
- How to use something like meta_query but for fields?
- Can’t get_users info by using json_encode
- Changing WordPress author name in database
- Efficient way of querying for a “fallback” post?
- Loop 1 user randomly
- List users in a dropdown for login
- How to set max users to 17.000
- Trying to display user meta by “name” – not by “ID”
- How to ‘remember’ a site member’s last visited page?
- How to connect database table to each registered wordpress user.
- Display a list of users with avatar filterable with alphabets
- Dynamically append custom post type to end of url
- Cross origin ajax request always returns 0 when calling get_current_user_id();
- Parse error: syntax error, unexpected ‘}’ in C:\wamp64\www\Proiect\aplicatie\user_check.php on line 18 [closed]
- Check if username doesn’t exists
- Too many if’s and else if’s ?? – Must be better way [closed]
- One folder to be accessible by one user
- WP query with variables gives no result for specific user
- Import users and custom user meta from csv
- How to lock users account until approvation
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Getting invalid user ID error when creating a new user with wp_insert_user
- How to create a User Role and give permission to only use Web Stories plugin?
- How to add custom user role into wordpress
- Redirect WordPress page to the latest created post by the logged in author/user