userpro_ajax_url我有一个 AJAX 函数,可以在通过 Facebook 成功登录后发送信息。
do_action我正在尝试使用以下方法获得成功块来运行函数
<?php
ob_start();
do_action('userpro_social_login', <email needs to go here>);
ob_clean();
?>
Run Code Online (Sandbox Code Playgroud)
现在,如果我手动传递电子邮件地址,它可以正常工作,但是我可以动态获取电子邮件的唯一方法是通过 JavaScript 中的当前响应。
完整的功能是:
FB.api('/me?fields=name,email,first_name,last_name,gender', function(response) {
jQuery.ajax({
url: userpro_ajax_url,
data: "action=userpro_fbconnect&id="+response.id+"&username="+response.username+"&first_name="+response.first_name+"&last_name="+response.last_name+"&gender="+response.gender+"&email="+response.email+"&name="+response.name+"&link="+response.link+"&profilepicture="+encodeURIComponent(profilepicture)+"&redirect="+redirect,
dataType: 'JSON',
type: 'POST',
success:function(data){
userpro_end_load( form );
<?php
ob_start();
do_action('userpro_social_login', );
ob_clean();
?>
/* custom message */
if (data.custom_message){
form.parents('.userpro').find('.userpro-body').prepend( data.custom_message );
}
/* redirect after form */
if (data.redirect_uri){
if (data.redirect_uri =='refresh') {
//document.location.href=jQuery(location).attr('href');
} else {
//document.location.href=data.redirect_uri;
}
}
},
error: function(){
alert('Something wrong happened.');
}
}); …Run Code Online (Sandbox Code Playgroud)