php [Membership 2 Pro] - 强制管理员对新订阅的待处理状态
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php [Membership 2 Pro] - 强制管理员对新订阅的待处理状态相关的知识,希望对你有一定的参考价值。
<?php
/*
Plugin Name: Membership - Force Pending status
Plugin URI: https://premium.wpmudev.org/
Description: Forces Pending status to new subscription made from admin
Author: Panos Lyrakis @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WPMUDEV_MS_Force_Pending' ) ) {
class WPMUDEV_MS_Force_Pending {
private static $_instance = null;
public static function get_instance() {
if( is_null( self::$_instance ) ){
self::$_instance = new WPMUDEV_MS_Force_Pending();
}
return self::$_instance;
}
public function __construct() {
add_action( 'ms_model_member_add_membership', array( $this, 'update_subscription_status' ), 10, 5 );
add_action( 'ms_model_relationship_handle_status_change_after', array( $this, 'send_notification' ), 10, 2 );
//add_action( 'ms_model_relationship_handle_status_change_after', array( $this, 'update_subscription_status' ), 10, 2 );
}
public function update_subscription_status( $subscription, $membership_id, $gateway_id, $move_from_id, $MS_Model_Member ){
global $pagenow;
if( ! is_admin() || $pagenow != 'admin.php' || ! isset( $_GET['page'] ) || $_GET['page'] != 'membership2-add-member' ){
return $subscription;
}
$data = $_POST;
if( empty( $data ) ||
! isset( $data['action'] ) || $data['action'] != 'member_subscription' ||
! isset( $data['user_id'] ) || ! is_numeric( $data['user_id'] ) ){
return $subscription;
}
//$membership_ids = isset( $data['subscribe'] ) && is_array( $data['subscribe'] ) ? $data['subscribe'] : false;
if( ! $data['subscribe'] || empty( $data['subscribe'] ) ){
return $subscription;
}
//$membership = MS_Factory::load( 'MS_Model_Membership', intval( $membership_id ) );
$subscription->handle_status_change( MS_Model_Relationship::STATUS_PENDING );
return $subscription;
}
public static function send_notification( $status, $subscription ){
global $pagenow;
if( ! is_admin() || $pagenow != 'admin.php' || ! isset( $_GET['page'] ) || $_GET['page'] != 'membership2-add-member' ){
return;
}
$data = $_POST;
if( empty( $data ) ||
! isset( $data['action'] ) || $data['action'] != 'member_subscription' ||
! isset( $data['user_id'] ) || ! is_numeric( $data['user_id'] ) ){
return;
}
if( ! $data['subscribe'] || empty( $data['subscribe'] ) ){
return;
}
$membership = MS_Factory::load( 'MS_Model_Membership', intval( $subscription->membership_id ) );
$user_id = absint( $data['user_id'] );
$user = MS_Factory::load( 'MS_Model_Member', $user_id );
$blog_title = get_bloginfo( 'name' );
$blog_email = get_bloginfo( 'admin_email' );
$checkout_url = MS_Model_Pages::get_page_url( MS_Model_Pages::MS_PAGE_MEMBERSHIPS ). '?step=payment_tablemembership_id=' . $subscription->membership_id;
$notification_subject = "You have a new Pending membership!";
$notification_body = "<p>Hi {$user->name}!</p>";
$notification_body .= "<p>You have a new subscription on {$blog_title} for membership <srong>{$membership->name}</strong> which is currently pending</p>";
$notification_body .= "<p>Please follow this <a href='{$checkout_url}'>activation link</a> in order to activate the subscription</p>";
$notification_body .= "<p>The {$blog_title} team</p>";
//$headers = array("Content-Type: text/html; charset=UTF-8","From: {$blog_title} <{$blog_email}>");
wp_mail( $user->email, $notification_subject, $notification_body );
}
}
add_action( 'plugins_loaded', function(){
$GLOBALS['WPMUDEV_MS_Force_Pending'] = WPMUDEV_MS_Force_Pending::get_instance();
}, 10 );
}
以上是关于php [Membership 2 Pro] - 强制管理员对新订阅的待处理状态的主要内容,如果未能解决你的问题,请参考以下文章
php [Membership 2 Pro]隐藏存档列表中的摘录
php [Membership 2 Pro] - 向尚未支付订阅费用的会员添加付款通知
php [Membership 2 Pro] - 强制管理员对新订阅的待处理状态
php Cron的工作是将wordpress用户添加到特定的Membership 2 Pro会员/订阅中
php integracióndewoocommerce con pay membership pro #wordpress #woocommerce