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:
- Matching a space in regex
- Create a global variable for use in all templates
- Integrating WordPress to my website, while keeping my own authentication system
- How to auto login user again after change user_login
- How to make an meta_query optional?
- How to update single value in multi dimensional Post Meta?
- Showing user ID on user main page from screen options
- Getting the Current User
- Authenticating to WordPress, using my own authentication two-factor system
- How to track a users progress through pages by inserting data into WordPress Database?
- 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?
- Delete option value from array using update_option()
- 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?
- Add New User, extra fields which are required?
- user_profile_update_errors hook not executing
- Modify user profile data through scripting?
- Extend PHP regex to cover “srcset” and “style” attributes
- Do not execute If User is login as Administrator or any Specific Role
- Custom query, checking values of multiple meta keys
- Archive post by meta value + 24hours
- Best practice for show data to one specific user?
- 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
- How to show a users bio on a page
- “operation successful” message
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Preg_Match(): compilation failed unknown property name
- php if username is role
- preg_replace regex problem
- Show current user posts only
- php preg_match with multiple patterns
- How to hide posts of a specific custom category in WordPress?
- Passing an array into WP_Query as a variable
- WordPress meta_query >= &
- Show site content based on user role
- php return username of currently viewed author profile
- How to list users like an archive page 10 users on page and have navigations
- Redirect to current user page upon link click
- Use of antispambot with $curauth->email
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Generate a QR code when creating a new WordPress user
- Change wordpress’ database data using ajax – how to get current user id?
- Sort column in Users admin Tab
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- Allow a user or role to view drafts and previews, but not other admin privileges?
- Woocommerce display orders with products from specific categories to specific admins
- wp_Query with mutuplea values returns all posts
- Admin Panel 404 Error after login
- meta_query search names when they have middle initials
- How to block specific user id in custom login form?
- Get current user id in function php
- how can I call a function when time expire
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- Uploading/integrating custom user registration page
- If user has clicked link add class and store using PHP/WordPress
- Store data from JavaScript object to custom table in user account
- Page template not working when logged out
- How to change the value of a variable using input field?
- How do I track which user clicked my button?
- Meta query not showing result properly
- 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
- WordPress add_rewrite_rule
- wordpress more than one ajax request at the same time issue
- How to use something like meta_query but for fields?
- Editable Student file associated with basic User ID
- Adding users to another blog
- Changing WordPress author name in database
- 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
- How to ‘remember’ a site member’s last visited page?
- How to connect database table to each registered wordpress user.
- 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
- 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]
- Check if username doesn’t exists
- Too many if’s and else if’s ?? – Must be better way [closed]
- WP query with variables gives no result for specific user
- How to lock users account until approvation
- get second ID from array
- 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