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?
- Matching a space in regex
- Correct regex for wp_embed_register_handler
- Create a global variable for use in all templates
- Add extra field to users
- Integrating WordPress to my website, while keeping my own authentication system
- Display user’s total comment count outside The Loop
- Changing user_nicename
- How to auto login user again after change user_login
- What is the most efficient way to search users by their display name?
- How to make an meta_query optional?
- Can i check if user is doing any ajax request?
- How do I create a WP user outside of WordPress and auto login?
- How to update single value in multi dimensional Post Meta?
- 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
- How to track a users progress through pages by inserting data into WordPress Database?
- Modern Tribe Calendar wp-query with meta query not working at all
- automated tests as a user?
- 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?
- Sortable admin column for one meta key with three possible meta values
- 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
- Wrap First Character after in a tag
- List User order by ID in Descending order (Backend)
- Warning: Use of undefined constant HTTP_USER_AGENT – assumed ‘HTTP_USER_AGENT’ (this will throw an Error in a future version of PHP)
- 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 with custom Shortcode
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- User’s total comment count excluding comments on their own posts
- User management system similar to wordpress one?
- How do I track which user clicked my button?
- Help hooking into user_register
- Meta query not showing result properly
- Use WP user status (logged_in) to manage access to independent application
- Add another role to a user when they click a button?
- Query to show average # of months all accounts with specific role have been active
- is_user_logged_in() not working in homepage
- 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
- WP_query meta_query slow with OR and DATES
- Get meta_query value by user meta array
- How to use something like meta_query but for fields?
- Can’t get_users info by using json_encode
- Editable Student file associated with basic User ID
- Adding users to another blog
- Changing WordPress author name in database
- Matching multi user
- Efficient way of querying for a “fallback” post?
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Updating custom user meta
- Loop 1 user randomly
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Update only some custom user fields
- 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”
- main menu page redirects to user ID
- How to ‘remember’ a site member’s last visited page?
- How to connect database table to each registered wordpress user.
- Adapting a php array to WordPress
- Get author meta of all writers
- Let users register weight each day and save it in DB
- 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();
- How to strip/remove all blank spaces at the beginning/end of a search string
- Parse error: syntax error, unexpected ‘}’ in C:\wamp64\www\Proiect\aplicatie\user_check.php on line 18 [closed]
- Forbid certain users to access a specific page
- 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
- Is there a way to get wp_editor (tinymce) content?
- Getting invalid user ID error when creating a new user with wp_insert_user
- get second ID from array
- How to cut a section of a URL from a string with a regular expression?
- How to create a User Role and give permission to only use Web Stories plugin?
- How to create custom user role without plugin?
- PHP Works only for logged in users: [closed]
- Custom Admin Menu Report for Specific User ID
- How to add custom user role into wordpress
- Redirect WordPress page to the latest created post by the logged in author/user
- Only registered users can see part of the contents of single.php
- change Dashboard default page on login
- Display posts in correct month order using single date custom field