custom.php
6 years ago
email.php
6 years ago
option.php
6 years ago
post.php
6 years ago
term.php
6 years ago
user.php
6 years ago
user.php
606 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | if(!class_exists('acfe_form_user')): |
| 7 | |
| 8 | class acfe_form_user{ |
| 9 | |
| 10 | function __construct(){ |
| 11 | |
| 12 | /* |
| 13 | * Form |
| 14 | */ |
| 15 | add_filter('acfe/form/load/action/user', array($this, 'load'), 1, 2); |
| 16 | add_action('acfe/form/submit/action/user', array($this, 'submit'), 1, 2); |
| 17 | |
| 18 | /* |
| 19 | * Admin |
| 20 | */ |
| 21 | add_filter('acf/prepare_field/name=acfe_form_user_save_meta', array(acfe()->acfe_form, 'map_fields')); |
| 22 | add_filter('acf/prepare_field/name=acfe_form_user_load_meta', array(acfe()->acfe_form, 'map_fields_deep')); |
| 23 | |
| 24 | add_filter('acf/prepare_field/name=acfe_form_user_map_email', array(acfe()->acfe_form, 'map_fields_deep')); |
| 25 | add_filter('acf/prepare_field/name=acfe_form_user_map_username', array(acfe()->acfe_form, 'map_fields_deep')); |
| 26 | add_filter('acf/prepare_field/name=acfe_form_user_map_password', array(acfe()->acfe_form, 'map_fields_deep')); |
| 27 | add_filter('acf/prepare_field/name=acfe_form_user_map_first_name', array(acfe()->acfe_form, 'map_fields_deep')); |
| 28 | add_filter('acf/prepare_field/name=acfe_form_user_map_last_name', array(acfe()->acfe_form, 'map_fields_deep')); |
| 29 | add_filter('acf/prepare_field/name=acfe_form_user_map_nickname', array(acfe()->acfe_form, 'map_fields_deep')); |
| 30 | add_filter('acf/prepare_field/name=acfe_form_user_map_display_name', array(acfe()->acfe_form, 'map_fields_deep')); |
| 31 | add_filter('acf/prepare_field/name=acfe_form_user_map_website', array(acfe()->acfe_form, 'map_fields_deep')); |
| 32 | add_filter('acf/prepare_field/name=acfe_form_user_map_description', array(acfe()->acfe_form, 'map_fields_deep')); |
| 33 | add_filter('acf/prepare_field/name=acfe_form_user_map_role', array(acfe()->acfe_form, 'map_fields_deep')); |
| 34 | |
| 35 | } |
| 36 | |
| 37 | function load($form, $post_id){ |
| 38 | |
| 39 | $form_name = acf_maybe_get($form, 'form_name'); |
| 40 | $form_id = acf_maybe_get($form, 'form_id'); |
| 41 | $post_info = acf_get_post_id_info($post_id); |
| 42 | |
| 43 | // Action |
| 44 | $user_action = get_sub_field('acfe_form_user_action'); |
| 45 | |
| 46 | // Load values |
| 47 | $load_values = get_sub_field('acfe_form_user_load_values'); |
| 48 | $load_source = get_sub_field('acfe_form_user_load_source'); |
| 49 | $load_meta = get_sub_field('acfe_form_user_load_meta'); |
| 50 | |
| 51 | // Load values |
| 52 | if(!$load_values) |
| 53 | return $form; |
| 54 | |
| 55 | $_email = get_sub_field('acfe_form_user_map_email'); |
| 56 | $_username = get_sub_field('acfe_form_user_map_username'); |
| 57 | $_password = get_sub_field('acfe_form_user_map_password'); |
| 58 | $_first_name = get_sub_field('acfe_form_user_map_first_name'); |
| 59 | $_last_name = get_sub_field('acfe_form_user_map_last_name'); |
| 60 | $_nickname = get_sub_field('acfe_form_user_map_nickname'); |
| 61 | $_display_name = get_sub_field('acfe_form_user_map_display_name'); |
| 62 | $_website = get_sub_field('acfe_form_user_map_website'); |
| 63 | $_description = get_sub_field('acfe_form_user_map_description'); |
| 64 | $_role = get_sub_field('acfe_form_user_map_role'); |
| 65 | |
| 66 | // Custom User ID |
| 67 | $_user_id = $load_source; |
| 68 | |
| 69 | // Current User |
| 70 | if($load_source === 'current_user'){ |
| 71 | |
| 72 | $_user_id = get_current_user_id(); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | // Current Post Author |
| 77 | elseif($load_source === 'current_post_author'){ |
| 78 | |
| 79 | if($post_info['type'] === 'post') |
| 80 | $_user_id = get_post_field('post_author', $post_id); |
| 81 | |
| 82 | } |
| 83 | |
| 84 | $_user_id = apply_filters('acfe/form/load/action/user/' . $user_action . '_id', $_user_id, $form); |
| 85 | $_user_id = apply_filters('acfe/form/load/action/user/' . $user_action . '_id/name=' . $form_name, $_user_id, $form); |
| 86 | $_user_id = apply_filters('acfe/form/load/action/user/' . $user_action . '_id/id=' . $form_id, $_user_id, $form); |
| 87 | |
| 88 | // Invalid User ID |
| 89 | if(!$_user_id) |
| 90 | return $form; |
| 91 | |
| 92 | $user_data = get_userdata($_user_id); |
| 93 | |
| 94 | // Check if userdata has been found |
| 95 | if(!$user_data) |
| 96 | return $form; |
| 97 | |
| 98 | |
| 99 | if(acf_is_field_key($_email)){ |
| 100 | |
| 101 | $key = array_search($_email, $load_meta); |
| 102 | |
| 103 | if($key !== false){ |
| 104 | |
| 105 | unset($load_meta[$key]); |
| 106 | $form['map'][$_email]['value'] = $user_data->user_email; |
| 107 | |
| 108 | } |
| 109 | |
| 110 | } |
| 111 | |
| 112 | // Username |
| 113 | if(acf_is_field_key($_username)){ |
| 114 | |
| 115 | $key = array_search($_username, $load_meta); |
| 116 | |
| 117 | if($key !== false){ |
| 118 | |
| 119 | unset($load_meta[$key]); |
| 120 | $form['map'][$_username]['value'] = $user_data->user_login; |
| 121 | $form['map'][$_username]['maxlength'] = 60; |
| 122 | |
| 123 | } |
| 124 | |
| 125 | } |
| 126 | |
| 127 | // Password |
| 128 | if(acf_is_field_key($_password)){ |
| 129 | |
| 130 | $key = array_search($_password, $load_meta); |
| 131 | |
| 132 | if($key !== false){ |
| 133 | |
| 134 | unset($load_meta[$key]); |
| 135 | //$form['map'][$_password]['value'] = $user_data->user_pass; |
| 136 | |
| 137 | } |
| 138 | |
| 139 | } |
| 140 | |
| 141 | // First name |
| 142 | if(acf_is_field_key($_first_name)){ |
| 143 | |
| 144 | $key = array_search($_first_name, $load_meta); |
| 145 | |
| 146 | if($key !== false){ |
| 147 | |
| 148 | unset($load_meta[$key]); |
| 149 | $form['map'][$_first_name]['value'] = $user_data->first_name; |
| 150 | |
| 151 | } |
| 152 | |
| 153 | } |
| 154 | |
| 155 | // Last name |
| 156 | if(acf_is_field_key($_last_name)){ |
| 157 | |
| 158 | $key = array_search($_last_name, $load_meta); |
| 159 | |
| 160 | if($key !== false){ |
| 161 | |
| 162 | unset($load_meta[$key]); |
| 163 | $form['map'][$_last_name]['value'] = $user_data->last_name; |
| 164 | |
| 165 | } |
| 166 | |
| 167 | } |
| 168 | |
| 169 | // Nickname |
| 170 | if(acf_is_field_key($_nickname)){ |
| 171 | |
| 172 | $key = array_search($_nickname, $load_meta); |
| 173 | |
| 174 | if($key !== false){ |
| 175 | |
| 176 | unset($load_meta[$key]); |
| 177 | $form['map'][$_nickname]['value'] = $user_data->nickname; |
| 178 | |
| 179 | } |
| 180 | |
| 181 | } |
| 182 | |
| 183 | // Display name |
| 184 | if(acf_is_field_key($_display_name)){ |
| 185 | |
| 186 | $key = array_search($_display_name, $load_meta); |
| 187 | |
| 188 | if($key !== false){ |
| 189 | |
| 190 | unset($load_meta[$key]); |
| 191 | $form['map'][$_display_name]['value'] = $user_data->display_name; |
| 192 | |
| 193 | } |
| 194 | |
| 195 | } |
| 196 | |
| 197 | // Website |
| 198 | if(acf_is_field_key($_website)){ |
| 199 | |
| 200 | $key = array_search($_website, $load_meta); |
| 201 | |
| 202 | if($key !== false){ |
| 203 | |
| 204 | unset($load_meta[$key]); |
| 205 | $form['map'][$_website]['value'] = $user_data->website; |
| 206 | |
| 207 | } |
| 208 | |
| 209 | } |
| 210 | |
| 211 | // Description |
| 212 | if(acf_is_field_key($_description)){ |
| 213 | |
| 214 | $key = array_search($_description, $load_meta); |
| 215 | |
| 216 | if($key !== false){ |
| 217 | |
| 218 | unset($load_meta[$key]); |
| 219 | $form['map'][$_description]['value'] = $user_data->description; |
| 220 | |
| 221 | } |
| 222 | |
| 223 | } |
| 224 | |
| 225 | // Role |
| 226 | if(acf_is_field_key($_role)){ |
| 227 | |
| 228 | $key = array_search($_role, $load_meta); |
| 229 | |
| 230 | if($key !== false){ |
| 231 | |
| 232 | unset($load_meta[$key]); |
| 233 | $form['map'][$_role]['value'] = implode(', ', $user_data->roles); |
| 234 | |
| 235 | } |
| 236 | |
| 237 | } |
| 238 | |
| 239 | // Load others values |
| 240 | if(!empty($load_meta)){ |
| 241 | |
| 242 | foreach($load_meta as $field_key){ |
| 243 | |
| 244 | $field = acf_get_field($field_key); |
| 245 | |
| 246 | $form['map'][$field_key]['value'] = acf_get_value('user_' . $_user_id, $field); |
| 247 | |
| 248 | } |
| 249 | |
| 250 | } |
| 251 | |
| 252 | return $form; |
| 253 | |
| 254 | } |
| 255 | |
| 256 | function submit($form, $post_id){ |
| 257 | |
| 258 | $form_name = acf_maybe_get($form, 'form_name'); |
| 259 | $form_id = acf_maybe_get($form, 'form_id'); |
| 260 | $post_info = acf_get_post_id_info($post_id); |
| 261 | |
| 262 | // Action |
| 263 | $user_action = get_sub_field('acfe_form_user_action'); |
| 264 | |
| 265 | // Mapping |
| 266 | $map = array( |
| 267 | 'user_email' => get_sub_field('acfe_form_user_map_email'), |
| 268 | 'user_login' => get_sub_field('acfe_form_user_map_username'), |
| 269 | 'user_pass' => get_sub_field('acfe_form_user_map_password'), |
| 270 | 'first_name' => get_sub_field('acfe_form_user_map_first_name'), |
| 271 | 'last_name' => get_sub_field('acfe_form_user_map_last_name'), |
| 272 | 'nickname' => get_sub_field('acfe_form_user_map_nickname'), |
| 273 | 'display_name' => get_sub_field('acfe_form_user_map_display_name'), |
| 274 | 'user_url' => get_sub_field('acfe_form_user_map_website'), |
| 275 | 'description' => get_sub_field('acfe_form_user_map_description'), |
| 276 | 'role' => get_sub_field('acfe_form_user_map_role'), |
| 277 | ); |
| 278 | |
| 279 | // Fields |
| 280 | $_target = get_sub_field('acfe_form_user_save_target'); |
| 281 | |
| 282 | $_user_email_group = get_sub_field('acfe_form_user_save_email_group'); |
| 283 | $_user_email = $_user_email_group['acfe_form_user_save_email']; |
| 284 | $_user_email_custom = $_user_email_group['acfe_form_user_save_email_custom']; |
| 285 | |
| 286 | $_user_login_group = get_sub_field('acfe_form_user_save_username_group'); |
| 287 | $_user_login = $_user_login_group['acfe_form_user_save_username']; |
| 288 | $_user_login_custom = $_user_login_group['acfe_form_user_save_username_custom']; |
| 289 | |
| 290 | $_user_pass_group = get_sub_field('acfe_form_user_save_password_group'); |
| 291 | $_user_pass = $_user_pass_group['acfe_form_user_save_password']; |
| 292 | $_user_pass_custom = $_user_pass_group['acfe_form_user_save_password_custom']; |
| 293 | |
| 294 | $_first_name_group = get_sub_field('acfe_form_user_save_first_name_group'); |
| 295 | $_first_name = $_first_name_group['acfe_form_user_save_first_name']; |
| 296 | $_first_name_custom = $_first_name_group['acfe_form_user_save_first_name_custom']; |
| 297 | |
| 298 | $_last_name_group = get_sub_field('acfe_form_user_save_last_name_group'); |
| 299 | $_last_name = $_last_name_group['acfe_form_user_save_last_name']; |
| 300 | $_last_name_custom = $_last_name_group['acfe_form_user_save_last_name_custom']; |
| 301 | |
| 302 | $_nickname_group = get_sub_field('acfe_form_user_save_nickname_group'); |
| 303 | $_nickname = $_nickname_group['acfe_form_user_save_nickname']; |
| 304 | $_nickname_custom = $_nickname_group['acfe_form_user_save_nickname_custom']; |
| 305 | |
| 306 | $_display_name_group = get_sub_field('acfe_form_user_save_display_name_group'); |
| 307 | $_display_name = $_display_name_group['acfe_form_user_save_display_name']; |
| 308 | $_display_name_custom = $_display_name_group['acfe_form_user_save_display_name_custom']; |
| 309 | |
| 310 | $_user_url_group = get_sub_field('acfe_form_user_save_website_group'); |
| 311 | $_user_url = $_user_url_group['acfe_form_user_save_website']; |
| 312 | $_user_url_custom = $_user_url_group['acfe_form_user_save_website_custom']; |
| 313 | |
| 314 | $_description_group = get_sub_field('acfe_form_user_save_description_group'); |
| 315 | $_description = $_description_group['acfe_form_user_save_description']; |
| 316 | $_description_custom = $_description_group['acfe_form_user_save_description_custom']; |
| 317 | |
| 318 | $_role = get_sub_field('acfe_form_user_save_role'); |
| 319 | |
| 320 | // args |
| 321 | $args = array(); |
| 322 | |
| 323 | // Insert user |
| 324 | $_user_id = 0; |
| 325 | |
| 326 | // Update user |
| 327 | if($user_action === 'update_user'){ |
| 328 | |
| 329 | // Custom User ID |
| 330 | $_user_id = $_target; |
| 331 | |
| 332 | // Current User |
| 333 | if($_target === 'current_user'){ |
| 334 | |
| 335 | $_user_id = get_current_user_id(); |
| 336 | |
| 337 | } |
| 338 | |
| 339 | // Current Post Author |
| 340 | elseif($_target === 'current_post_author'){ |
| 341 | |
| 342 | if($post_info['type'] === 'post') |
| 343 | $_user_id = get_post_field('post_author', $post_info['id']); |
| 344 | |
| 345 | // Invalid User ID |
| 346 | if(!$_user_id) |
| 347 | return; |
| 348 | |
| 349 | } |
| 350 | |
| 351 | // ID |
| 352 | $args['ID'] = $_user_id; |
| 353 | |
| 354 | } |
| 355 | |
| 356 | |
| 357 | if(!empty($map['user_email'])){ |
| 358 | |
| 359 | $args['user_email'] = acfe_form_map_field_value($map['user_email'], $_POST['acf'], $_user_id); |
| 360 | |
| 361 | }elseif($_user_email === 'custom'){ |
| 362 | |
| 363 | $args['user_email'] = acfe_form_map_field_value($_user_email_custom, $_POST['acf'], $_user_id); |
| 364 | |
| 365 | } |
| 366 | |
| 367 | // Username |
| 368 | if(!empty($map['user_login'])){ |
| 369 | |
| 370 | $args['user_login'] = acfe_form_map_field_value($map['user_login'], $_POST['acf'], $_user_id); |
| 371 | |
| 372 | }elseif($_user_login === 'custom'){ |
| 373 | |
| 374 | $args['user_login'] = acfe_form_map_field_value($_user_login_custom, $_POST['acf'], $_user_id); |
| 375 | |
| 376 | } |
| 377 | |
| 378 | // Password |
| 379 | if(!empty($map['user_pass'])){ |
| 380 | |
| 381 | $args['user_pass'] = acfe_form_map_field_value($map['user_pass'], $_POST['acf'], $_user_id); |
| 382 | |
| 383 | }elseif($_user_pass === 'generate_password'){ |
| 384 | |
| 385 | $args['user_pass'] = wp_generate_password(8, false); |
| 386 | |
| 387 | }elseif($_user_pass === 'custom'){ |
| 388 | |
| 389 | $args['user_pass'] = acfe_form_map_field_value($_user_pass_custom, $_POST['acf'], $_user_id); |
| 390 | |
| 391 | } |
| 392 | |
| 393 | // First name |
| 394 | if(!empty($map['first_name'])){ |
| 395 | |
| 396 | $args['first_name'] = acfe_form_map_field_value($map['first_name'], $_POST['acf'], $_user_id); |
| 397 | |
| 398 | }elseif($_first_name === 'custom'){ |
| 399 | |
| 400 | $args['first_name'] = acfe_form_map_field_value($_first_name_custom, $_POST['acf'], $_user_id); |
| 401 | |
| 402 | } |
| 403 | |
| 404 | // Last name |
| 405 | if(!empty($map['last_name'])){ |
| 406 | |
| 407 | $args['last_name'] = acfe_form_map_field_value($map['last_name'], $_POST['acf'], $_user_id); |
| 408 | |
| 409 | }elseif($_last_name === 'custom'){ |
| 410 | |
| 411 | $args['last_name'] = acfe_form_map_field_value($_last_name_custom, $_POST['acf'], $_user_id); |
| 412 | |
| 413 | } |
| 414 | |
| 415 | // Nickname |
| 416 | if(!empty($map['nickname'])){ |
| 417 | |
| 418 | $args['nickname'] = acfe_form_map_field_value($map['nickname'], $_POST['acf'], $_user_id); |
| 419 | |
| 420 | }elseif($_nickname === 'custom'){ |
| 421 | |
| 422 | $args['nickname'] = acfe_form_map_field_value($_nickname_custom, $_POST['acf'], $_user_id); |
| 423 | |
| 424 | } |
| 425 | |
| 426 | // Display name |
| 427 | if(!empty($map['display_name'])){ |
| 428 | |
| 429 | $args['display_name'] = acfe_form_map_field_value($map['display_name'], $_POST['acf'], $_user_id); |
| 430 | |
| 431 | }elseif($_display_name === 'custom'){ |
| 432 | |
| 433 | $args['display_name'] = acfe_form_map_field_value($_display_name_custom, $_POST['acf'], $_user_id); |
| 434 | |
| 435 | } |
| 436 | |
| 437 | // Website |
| 438 | if(!empty($map['user_url'])){ |
| 439 | |
| 440 | $args['user_url'] = acfe_form_map_field_value($map['user_url'], $_POST['acf'], $_user_id); |
| 441 | |
| 442 | }elseif($_user_url === 'custom'){ |
| 443 | |
| 444 | $args['user_url'] = acfe_form_map_field_value($_user_url_custom, $_POST['acf'], $_user_id); |
| 445 | |
| 446 | } |
| 447 | |
| 448 | // Description |
| 449 | if(!empty($map['description'])){ |
| 450 | |
| 451 | $args['description'] = acfe_form_map_field_value($map['description'], $_POST['acf'], $_user_id); |
| 452 | |
| 453 | }elseif($_description === 'custom'){ |
| 454 | |
| 455 | $args['description'] = acfe_form_map_field_value($_description_custom, $_POST['acf'], $_user_id); |
| 456 | |
| 457 | } |
| 458 | |
| 459 | // Role |
| 460 | if(!empty($map['role'])){ |
| 461 | |
| 462 | $args['role'] = acfe_form_map_field_value($map['role'], $_POST['acf'], $_user_id); |
| 463 | |
| 464 | }elseif(!empty($_role)){ |
| 465 | |
| 466 | $args['role'] = $_role; |
| 467 | |
| 468 | } |
| 469 | |
| 470 | $args = apply_filters('acfe/form/submit/action/user/' . $user_action . '_args', $args, $form); |
| 471 | $args = apply_filters('acfe/form/submit/action/user/' . $user_action . '_args/name=' . $form_name, $args, $form); |
| 472 | $args = apply_filters('acfe/form/submit/action/user/' . $user_action . '_args/id=' . $form_id, $args, $form); |
| 473 | |
| 474 | // Insert User |
| 475 | if($user_action === 'insert_user'){ |
| 476 | |
| 477 | if(!isset($args['user_email']) || !isset($args['user_login']) || !isset($args['user_pass'])){ |
| 478 | |
| 479 | $args = false; |
| 480 | |
| 481 | } |
| 482 | |
| 483 | } |
| 484 | |
| 485 | if($args === false) |
| 486 | return; |
| 487 | |
| 488 | // Insert User |
| 489 | if($user_action === 'insert_user'){ |
| 490 | |
| 491 | $_insert_user = wp_insert_user($args); |
| 492 | |
| 493 | } |
| 494 | |
| 495 | // Update User |
| 496 | elseif($user_action === 'update_user'){ |
| 497 | |
| 498 | $_insert_user = wp_update_user($args); |
| 499 | |
| 500 | if(!is_wp_error($_insert_user)){ |
| 501 | |
| 502 | $_user_id = $_insert_user; |
| 503 | |
| 504 | // Update User Login + Nicename |
| 505 | if(acf_maybe_get($args, 'user_login')){ |
| 506 | |
| 507 | // Sanitize |
| 508 | $sanitized_user_login = sanitize_user($args['user_login'], true); |
| 509 | |
| 510 | // Filter |
| 511 | $pre_user_login = apply_filters('pre_user_login', $sanitized_user_login); |
| 512 | |
| 513 | // Trim |
| 514 | $user_login = trim($pre_user_login); |
| 515 | |
| 516 | $error = false; |
| 517 | |
| 518 | if(empty($user_login)){ |
| 519 | |
| 520 | $error = new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.')); |
| 521 | |
| 522 | }elseif(mb_strlen($user_login) > 60){ |
| 523 | |
| 524 | $error = new WP_Error('user_login_too_long', __('Username may not be longer than 60 characters.')); |
| 525 | |
| 526 | } |
| 527 | |
| 528 | if(username_exists($user_login)){ |
| 529 | |
| 530 | $error = new WP_Error('existing_user_login', __('Sorry, that username already exists!')); |
| 531 | |
| 532 | } |
| 533 | |
| 534 | $user_nicename = sanitize_user($user_login, true); |
| 535 | |
| 536 | if(mb_strlen($user_nicename) > 50){ |
| 537 | |
| 538 | $error = new WP_Error('user_nicename_too_long', __('Nicename may not be longer than 50 characters.')); |
| 539 | |
| 540 | } |
| 541 | |
| 542 | $user_nicename = sanitize_title($user_nicename); |
| 543 | |
| 544 | $user_nicename = apply_filters('pre_user_nicename', $user_nicename); |
| 545 | |
| 546 | if(!is_wp_error($error)){ |
| 547 | |
| 548 | global $wpdb; |
| 549 | |
| 550 | $wpdb->update($wpdb->users, |
| 551 | array( |
| 552 | 'user_login' => $user_login, |
| 553 | 'user_nicename' => $user_nicename, |
| 554 | ), |
| 555 | array( |
| 556 | 'ID' => $_user_id |
| 557 | ) |
| 558 | ); |
| 559 | |
| 560 | } |
| 561 | |
| 562 | } |
| 563 | |
| 564 | } |
| 565 | |
| 566 | } |
| 567 | |
| 568 | // User Error |
| 569 | if(is_wp_error($_insert_user)) |
| 570 | return; |
| 571 | |
| 572 | $_user_id = $_insert_user; |
| 573 | |
| 574 | do_action('acfe/form/submit/action/user/' . $user_action, $form, $_user_id, $args); |
| 575 | do_action('acfe/form/submit/action/user/' . $user_action . '/name=' . $form_name, $form, $_user_id, $args); |
| 576 | do_action('acfe/form/submit/action/user/' . $user_action . '/id=' . $form_id, $form, $_user_id, $args); |
| 577 | |
| 578 | // Meta save |
| 579 | $save_meta = get_sub_field('acfe_form_user_save_meta'); |
| 580 | |
| 581 | if(!empty($save_meta)){ |
| 582 | |
| 583 | $data = acfe_form_filter_meta($save_meta, $_POST['acf']); |
| 584 | |
| 585 | if(!empty($data)){ |
| 586 | |
| 587 | // Backup original acf post data |
| 588 | $acf = $_POST['acf']; |
| 589 | |
| 590 | // Save meta fields |
| 591 | acf_save_post('user_' . $_user_id, $data); |
| 592 | |
| 593 | // Restore original acf post data |
| 594 | $_POST['acf'] = $acf; |
| 595 | |
| 596 | } |
| 597 | |
| 598 | } |
| 599 | |
| 600 | } |
| 601 | |
| 602 | } |
| 603 | |
| 604 | new acfe_form_user(); |
| 605 | |
| 606 | endif; |