• Resolved Mikel

    (@ogmic)


    Hello, I want to show the phone number of the currently logged-in user using a shortcode… How do I do that please?

Viewing 1 replies (of 1 total)
  • Plugin Author Mostafa Soufi

    (@mostafas1990)

    Hi, use the below function on your functions.php

    function renderCurrentUserNumberShortCode($atts)
    {
        $currentUser = wp_get_current_user();
        $userMobile  = null;
    
        if ($currentUser instanceof WP_User) {
            $userMobile = get_user_meta($currentUser->ID, 'mobile', true);
        }
    
        return $userMobile;
    }
    add_shortcode('wp-sms-current-user-number', 'renderCurrentUserNumberShortCode');

    Then the shortcode is: [wp-sms-current-user-number]

    Best

Viewing 1 replies (of 1 total)

The topic ‘Shortcode to show current user number’ is closed to new replies.