2013-10-23 1 views
0

WordPress를 사용하여 다른 사용자가 중력 양식을 채울 때 함수를 수정하여 사용자 메타 데이터를 업데이트합니다. 업데이트하고 싶은 메타 데이터는 맞춤 프로필 정보입니다. 백 엔드에서 데이터를 올바르게 업데이트하지만 폼을 통해 수행 할 수는 없습니다.사용자 정의 프로필 infrmation으로 사용자 메타 데이터 업데이트

내가 잘못 본 곳을 정말로 볼 수 없습니다.

function GF_setup_actions_filters() { 
     $_gf_edit_profile_id = RGFormsModel::get_form_id('25'); 
     add_action('gform_after_submission_25' . $_gf_edit_profile_id, 'GF_update_profile', 100, 2); } 

function GF_get_profile_fields() { 
     $_fields['share_a_little'] = array ('gf_index' => '4', 'wp_meta' => 'share_a_little'); 
     return $_fields; } 

function GF_update_profile($entry, $form) { 
    global $wpdb; 

    if (!is_user_logged_in()) { 
     wp_redirect(home_url()); 
     exit(); 
    } 


    $_user_id = get_current_user_id(); 
    $_user = new stdClass(); 
    $_user->ID = (int) $_user_id; 
    $_userdata = get_user_meta($_user_id); 
    $_user->user_login = $wpdb->escape($_userdata->user_login); 

    $gf_fields = GF_get_profile_fields(); 

    $share_a_little = $entry[$gf_fields['share_a_little']['4']]; 
    update_user_meta($_user->ID, 'share_a_little', $share_a_little); 
} 
+0

'GF_setup_actions_filters'를 실행시키는 고리는 어디에서 왔습니까? – brasofilo

답변

0

이 부분은 잘못되었습니다.

$_gf_edit_profile_id = RGFormsModel::get_form_id('25'); 
add_action('gform_after_submission_25' . $_gf_edit_profile_id, 'GF_update_profile', 100, 2); } 

양식 ID가 25이고, 형태는 25 선이로 대체해야 명명되지 않은 경우 : 25이라고하고 돈되는에서 경우

add_action('gform_after_submission_25', 'GF_update_profile', 100, 2); } 

; t 알고 ID는 선이 있어야한다 :

$_gf_edit_profile_id = RGFormsModel::get_form_id('25'); 
add_action('gform_after_submission_' . $_gf_edit_profile_id, 'GF_update_profile', 100, 2); } 

코드는 내가 중력 양식을 사용하여 사용자 프로필을 업데이트 다시 잠시 쓴 기사와 매우 비슷합니다. 코드 설명과 함께 here을 읽을 수 있습니다.

관련 문제