如何在客户注册时发送消息

时间:2017-04-26 作者:inrsaurabh

我正试图发送MESSAGES 当客户

注册或重置密码,或以后决定的任何特定事件

建议一些步骤。

我只想知道当客户注册时如何触发API。是否有任何可用的挂钩,我可以通过它触发我的自定义函数。

UPDATE : My Problem is solved & Thank You @TomC

 if ( is_user_logged_in() ) {

    $user_id = get_current_user_id();
    $registration_field_1 = get_user_meta( $user_id, \'registration_field_1\', true );
    $smsDone = get_user_meta( $user_id, \'smsDone\', true );

    if(!empty($smsDone) && $smsDone === \'True\'){
    }else{
        $respuesta = wp_remote_get( "http://apiWebsite.com/messageapi.asp?username=key&password=somepwd@1&sender=key2&mobile=".$registration_field_1."&message=Your%20Profile%20is%20registered%20successfully%20.%20You%20are%20precious%20to%20us%20and%20we%20are%20glad%20to%20serve%20you%20better.%20Regards,%20The%20Astrochannel%20Team.");
        update_user_meta( $user_id, \'smsDone\',\'True\'   ); 
    }
 } 
我使用这种方法在客户注册后发送短信。

1 个回复
最合适的回答,由SO网友:TomC 整理而成

如果您正在谈论Wordpress用户注册,那么您需要从阅读用户注册挂钩开始:https://codex.wordpress.org/Plugin_API/Action_Reference/user_register

然后,您的代码将是这样的,每次用户在站点上注册时都会自动触发:

add_action(\'user_register\',\'send_sms\');

function send_sms($user_id){
  // Code for your SMS API Here
}
代码将放在插件或主题的functions.php 文件如果你在谈论一个电子商务插件,你需要看看他们有哪些可用于客户注册的操作挂钩,并根据开发人员文档使用这些挂钩。

相关推荐

创建帖子,包含来自远程API的数据

我需要一些帮助和指导。因此,我正在开发一个网站(自定义主题),目标是从远程API获取数据。我希望能够将数据存储在各个帖子中(一种自定义帖子类型),当有人向远程API添加或删除数据时,它应该会更新网站上的帖子。我使用的API的结构如下:https://pippinsplugins.com/edd-api/products我知道如何从中获取数据并解码JSON等。$url = \'https://pippinsplugins.com/edd-api/products\'; $username