Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function my_acf_save__posts( $post_id ) {
- // get the user name field
- $first_name = get_field('twoje_imie', $post_id);
- $email = get_field('twoj_email', $post_id);
- $pass = wp_generate_password();
- // create the user
- $create = wp_create_user( $email, $pass, $email );
- if ((is_wp_error($create) || isset($_COOKIE['konkurs'])) && !current_user_can('manage_options')) {
- wp_delete_post($post_id);
- echo "Już dodałeś prace";
- exit;
- }
- $user = get_user_by_email($email);
- wp_update_user(['ID'=>$user->ID, 'first_name' => $first_name]);
- update_user_meta($user->ID, 'post_created', 1);
- wp_new_user_notification($user->ID);
- // delete the unused post
- $arg = array(
- 'ID' => $post_id,
- 'post_author' => $user->ID,
- );
- wp_update_post( $arg );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement