Skip to content

Instantly share code, notes, and snippets.

@ucheng
Created August 18, 2018 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ucheng/b9b4a80e6b5a9fef0078f4ac30431060 to your computer and use it in GitHub Desktop.
Save ucheng/b9b4a80e6b5a9fef0078f4ac30431060 to your computer and use it in GitHub Desktop.
bulk add user to subscription
<?php
function oneday_bulk_add_user_to_subscription() {
$args= array(
array( 'role' => 'Subscriber' )
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->get_results() ) ) {
foreach ( $user_query->get_results() as $user ) {
$rcp_args = array(
'subscription_id' => 1
'status' => 'active',
// 'expiration' => date( 'Y-m-d 23:59:59', strtotime( '+1 month', current_time( 'timestamp' ) ) ),
// 'discount_code' => 'free_subscription'
);
rcp_add_user_to_subscription( $user->ID, $rcp_args );
}
} else {
// echo 'No users found.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment