Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Mirza Hamza

    (@hamza1010)

    Hello @sroskylo1,

    Thanks for contacting us,

    I hope you are doing well, We have to check this and we will keep you updated on this.

    Thanks & Regards
    WP Experts Support Team

    Thread Starter sroskylos

    (@sroskylo1)

    Hello @hamza1010 ,

    Ok i will wait ??

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hello @sroskylo1,

    Yes, you can hide some characters of the user email from the leaderboard. Add the below code snippets in your active theme’s functions.php file.

    Here is the code:

    add_filter( 'mycred_ranking_row', 'mycredpro_add_masked_email_to_leaderboard', 10, 4 );
    function mycredpro_add_masked_email_to_leaderboard( $layout, $template, $user, $position ) {

    if ( isset( $user->ID ) )
    $user_id = $user->ID;

    elseif ( isset( $user['ID'] ) )
    $user_id = $user['ID'];

    else return $layout;

    // Get the user's email
    $user_info = get_userdata( $user_id );
    $email = $user_info->user_email;

    // Mask the email
    $masked_email = mask_email( $email );

    // Replace %email% placeholder with the masked email
    return str_replace( '%email%', esc_html( $masked_email ), $layout );
    }

    // Function to mask email (e.g., [email protected] to user***@exa***.com)
    function mask_email( $email ) {
    list( $username, $domain ) = explode( '@', $email );

    // Mask part of the username (first 3 characters shown, rest masked)
    $masked_username = substr( $username, 0, 3 ) . str_repeat( '*', strlen( $username ) - 3 );

    // Mask part of the domain (first 3 characters of domain shown, rest masked except TLD)
    $domain_parts = explode( '.', $domain );
    $masked_domain = substr( $domain_parts[0], 0, 3 ) . str_repeat( '*', strlen( $domain_parts[0] ) - 3 ) . '.' . $domain_parts[1];

    return $masked_username . '@' . $masked_domain;
    }

    Place the below shortcode on any page.

    <table>
    <thead>
    <tr>
    <th>Position</th>
    <th>Name</th>
    <th>Points</th>
    <th>Email</th>
    </tr>
    </thead>
    <tbody>
    [mycred_leaderboard wrap=""]
    <tr>
    <td>%position%</td>
    <td>%display_name%</td>
    <td>%cred_f%</td>
    <td>%email%</td>
    </tr>
    [/mycred_leaderboard]
    </tbody>
    </table>

    If you have any questions, feel free to reach out. We’re here to assist you.

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide The Username If Is email on leaderbord’ is closed to new replies.