من میخوام یک متغیری از گرویتی فرم (مثلا فیلد شماره 5 از فرم شماره 2) رو بعد از ثبت به مشخصات کاربر بفرستم (پروفایل کاربر رو بروز کنم)
فیلد جدید رو توی پروفایل ساختم و میشه ویرایشش کرد فقط مشکلم گرفتن مقدار فیلد و به روزرسانی پروفایل از گرویتی فرم هست
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) {
<input type="text" name="count" id="count" value="<?php echo esc_attr( get_the_author_meta( 'count', $user->ID ) ); ?>" disabled class="regular-text" />
}
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_usermeta( $user_id, 'count', $_POST['count'] );
}
این فقط برای قسمت پروفایل کاربر هست و قرار نیست کاربر بتونه مستقیم ویرایشش کنه فقط باید از طریق فرم پر بشه.
و تا جایی که بشه از پلاگین نمیخوام استفاده کنم
کسی میتونه کمکم کنه؟
فیلد جدید رو توی پروفایل ساختم و میشه ویرایشش کرد فقط مشکلم گرفتن مقدار فیلد و به روزرسانی پروفایل از گرویتی فرم هست
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) {
<input type="text" name="count" id="count" value="<?php echo esc_attr( get_the_author_meta( 'count', $user->ID ) ); ?>" disabled class="regular-text" />
}
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_usermeta( $user_id, 'count', $_POST['count'] );
}
این فقط برای قسمت پروفایل کاربر هست و قرار نیست کاربر بتونه مستقیم ویرایشش کنه فقط باید از طریق فرم پر بشه.
و تا جایی که بشه از پلاگین نمیخوام استفاده کنم
کسی میتونه کمکم کنه؟