CTXPS_Queries::add_membership_with_expiration() not working
-
Hi,
I am attempting to write a small plugin that scans my WP users list daily for new subscribers with a specific user meta value (member_type = ‘realtor’) and if a match if found I want to automatically add them to a previously created group called “Realtor” (group ID = 30).
My logic below seems to work fine and is able to get a list of all the right users, but then when it comes to iterating though that list and getting them added to the group, the code fails. I can’t find any specific errors in the WP Debug or PHP log.
Is there something I am missing to get your add_membership_with_expiration call to work?
function add_realtor_group_to_users() { $args = array( 'role' => 'subscriber', 'meta_query' => array( array( 'key' => 'member_type', 'value' => 'realtor', ), ) ); $wp_user_query = new WP_User_Query($args); $realtors = $wp_user_query->get_results(); if (!empty($realtors)) { foreach ($realtors as $realtor) { $result = CTXPS_Queries::add_membership_with_expiration($realtor->ID, 30); } } }
Thanks for your help!
- The topic ‘CTXPS_Queries::add_membership_with_expiration() not working’ is closed to new replies.