admin管理员组文章数量:1414621
I have a form in which user A with a custom role is able to invite other users. Javascript which handles that looks like this:
sendNotificationEmail(newUserId) {
newUserId = parseInt(newUserId);
$.ajax({
beforeSend: (xhr) => {
xhr.setRequestHeader('X-WP-Nonce', ftsData.nonce);
},
url: ftsData.root_url + '/wp-admin/admin-ajax.php',
type: 'POST',
dataType: 'JSON',
data: {
action: 'send_it_bro',
id : newUserId
},
success: (response) => {
console.log(response);
},
error: (response) => {
console.log(response);
},
});
}
In functions.php I have:
add_action ('wp_ajax_send_it_bro', 'send_it_bro') ;
function send_it_bro(){
$id = intval($_REQUEST['id']);
wp_send_new_user_notifications($id, 'both');
$return_value = $id ;
wp_send_json_success ($return_value) ;
}
When user with a role "admin" invites new users everything works well, but when a user with custom role invites users, then they don't get welcome e-mail.
本文标签: Adding user using admin ajax by a user with custom role
版权声明:本文标题:Adding user using admin ajax by a user with custom role 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745190862a2646903.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论