WordPress.org

Make WordPress Core

Ticket #39223: 39223.1.diff

File 39223.1.diff, 1.2 KB (added by Mista-Flo, 3 years ago)

Add signup_user_meta filter to edit meta array in wp_signup_user function

  • wp-includes/ms-functions.php

    diff --git wp-includes/ms-functions.php wp-includes/ms-functions.php
    index 2e9ca94..56f9afe 100644
    function wpmu_signup_user( $user, $user_email, $meta = array() ) { 
    720720        $user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );
    721721        $user_email = sanitize_email( $user_email );
    722722        $key = substr( md5( time() . rand() . $user_email ), 0, 16 );
    723         $meta = serialize($meta);
     723
     724        /**
     725         * Allow plugins to edit $meta array
     726         *
     727         * @since 4.8.0
     728         *
     729         * @param array  $meta       Additional signup meta. By default, this is an empty array.
     730         * @param string $user       The user's requested login name.
     731         * @param string $user_email The user's email address.
     732         * @param string $key        The user's activation key
     733         */
     734        $meta = apply_filters( 'signup_user_meta', $meta, $user, $user_email, $key );
    724735
    725736        $wpdb->insert( $wpdb->signups, array(
    726737                'domain' => '',
    function wpmu_signup_user( $user, $user_email, $meta = array() ) { 
    730741                'user_email' => $user_email,
    731742                'registered' => current_time('mysql', true),
    732743                'activation_key' => $key,
    733                 'meta' => $meta
     744                'meta' => serialize( $meta ),
    734745        ) );
    735746
    736747        /**