You appear to be a bot. Output may be restricted
Description
Jetpack_Subscriptions::subscribe()
Send a synchronous XML-RPC subscribe to blog posts or subscribe to post comments request.
Usage
$true|WP_Error = Jetpack_Subscriptions::subscribe( $email, $post_ids, $async, $extra_data );
Parameters
- ( string ) required –
- $post_ids
- ( array ) optional – (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts
- $async
- ( bool ) optional default: 1 – (optional) Should the subscription be performed asynchronously? Defaults to true.
- $extra_data
- ( mixed ) optional –
Returns
true|WP_Error true on success invalid_email : not a valid email address invalid_post_id : not a valid post ID unknown_post_id : unknown post not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email. disabled : Site owner has disabled subscriptions. active : Already subscribed. pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent. unknown : strange error. Jetpack servers at WordPress.com returned something malformed. unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
Source
File name: jetpack/modules/subscriptions.php
Lines:
function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) { if ( !is_email( $email ) ) { return new WP_Error( 'invalid_email' ); } if ( !$async ) { $xml = new Jetpack_IXR_ClientMulticall(); } foreach ( (array) $post_ids as $post_id ) { $post_id = (int) $post_id; if ( $post_id < 0 ) { return new WP_Error( 'invalid_post_id' ); } else if ( $post_id && !$post = get_post( $post_id ) ) { return new WP_Error( 'unknown_post_id' ); } if ( $async ) { XMLRPC_Async_Call::add_call( 'jetpack.subscribeToSite', 0, $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize } else { $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) ); } } if ( $async ) { return; } // Call $xml->query(); if ( $xml->isError() ) { return $xml->get_jetpack_error(); } $responses = $xml->getResponse(); $r = array(); foreach ( (array) $responses as $response ) { if ( isset( $response['faultCode'] ) || isset( $response['faultString'] ) ) { $r[] = $xml->get_jetpack_error( $response['faultCode'], $response['faultString'] ); continue; } if ( !is_array( $response[0] ) || empty( $response[0]['status'] ) ) { $r[] = new WP_Error( 'unknown' ); continue; } switch ( $response[0]['status'] ) { case 'error': $r[] = new WP_Error( 'not_subscribed' ); continue 2; case 'disabled': $r[] = new WP_Error( 'disabled' ); continue 2; case 'active': $r[] = new WP_Error( 'active' ); continue 2; case 'confirming': $r[] = true; continue 2; case 'pending': $r[] = new WP_Error( 'pending' ); continue 2; default: $r[] = new WP_Error( 'unknown_status', (string) $response[0]['status'] ); continue 2; } } return $r; }