wp_schedule_single_event()现有动作
不幸的是,尝试做这项工作,没有成功。 注册后5分钟,用户应收到一条消息。 有解决方案吗?
function bp_messages_first_message( $user_id = false, $key = false, $user = false ){
if ( ! function_exists( 'BP_Better_Messages' ) ) return false;
$args = array(
'sender_id' => 88,
'thread_id' => false,
'recipients' => $user_id,
'content' => "test",
'date_sent' => bp_core_current_time()
);
$result = BP_Better_Messages()->functions->new_message( $args );
}
function do_this_in_5_minutes() {
add_action('bp_core_activated_user', 'bp_messages_first_message', 10, 3);
}
add_action( 'message_5','do_this_in_5_minutes' );
wp_schedule_single_event( time() + 300, 'message_5' );
Trying do make this work, unfortunately without success.
The user should receive a message 5 minutes after registration.
Any solutions?
function bp_messages_first_message( $user_id = false, $key = false, $user = false ){
if ( ! function_exists( 'BP_Better_Messages' ) ) return false;
$args = array(
'sender_id' => 88,
'thread_id' => false,
'recipients' => $user_id,
'content' => "test",
'date_sent' => bp_core_current_time()
);
$result = BP_Better_Messages()->functions->new_message( $args );
}
function do_this_in_5_minutes() {
add_action('bp_core_activated_user', 'bp_messages_first_message', 10, 3);
}
add_action( 'message_5','do_this_in_5_minutes' );
wp_schedule_single_event( time() + 300, 'message_5' );
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
然后,在注册发生时安排事件是有意义的。
未测试:
Then it would make sense to schedule the event when the registration happens.
Not tested: