2014-01-09 6 views
1

사용자 상태를 확인하고 그에 따라 bbPress 포럼 역할을 업데이트하고 싶습니다. (Wordpress 역할이 아닙니다.)Wordpress - 사용자 상태를 확인하여 외부에서 bbPress 포럼 역할을 변경하십시오.

사용자 등록을 중재하는 BP 등록 옵션 플러그인에 BuddyPress 기능을 추가하는 것이 목적이며, 현재 플러그인은 사용자가 승인되지 않은 상태에서 사용자 상태를 69로 설정하고 BuddyPress 기능에 액세스 할 수 있지만 사용자는 여전히 로그인 할 수 있습니다.

사용자가 로그인하면 bbPress는 백엔드 설정에 따라 사용자 포럼 역할을 자동으로 설정합니다.이 경우 '관객 사용자가 관리자의 승인을 받아 상태가 변경되면 bbPress 역할을 '참가자'로 업데이트하려고합니다.

내 첫 시도는 다음과 같습니다

function bp_registration_options_additional() { 
    if (is_user_logged_in()) { 
    $user_ID = get_current_user_id(); 
    $user = get_userdata($user_ID); 
     if (69 !== $user->user_status) { 

     // Here is where I need help. 

    //How to set the bbPress forum role to 'Participant'? 

    } 
    } 
} 
add_action('wp_loaded', 'bp_registration_options_additional'); 

고마워요!

WP : 3.8 bbPress : 버전 2.5.2

편집 : 추가 정보의 비트. 포럼 역할에 대한 meta_key는 wp_capabilities입니다. 포럼 역할 '관객이있는 사용자의 meta_value; 입니다 : - wp_capabilities 필드를 업데이트하기 - a:2:{s:10:"subscriber";b:1;s:13:"bbp_spectator";b:1;}

답변

2

이 같은 요구를했다

$wp_user_capabilities_arr = array( "subscriber" => true, "bbp_participant" => true ); update_user_meta($wp_user_id, "wp_capabilities", $wp_user_capabilities_arr);

그리고 업데이트 후 데이터는 다음과 같습니다

A : 2 : {S : 10 : "가입자 "; b : 1; s : 15 :"bbp_participant "; b : 1;}