I'm trying to add the registration date of users (vendors) to my single store page. This would ideally read "member since (date)". I also want to use shortcode so I can apply this manually using Elementor Pro's shortcode widget. I'm adding the below code to my functions.php file in my child theme, however being hit with the "Member since information not available" message. NOTE: I am also using Dokan Pro theme, so not sure if this is conflicting at all?

function vendor_member_since_shortcode($atts) {
// Get the user ID of the vendor
$user_id = get_query_var('author');

// Get the user data
$udata = get_userdata($user_id);

// Check if user data is valid
if ($udata) {
    // Get the registration date
    $registered = $udata->user_registered;

    // Check if the registration date is valid
    if ($registered) {
        // Format the date
        $formatted_date = date("M Y", strtotime($registered));

        // Display the result
        return sprintf('%s member since %s', $udata->data->display_name, $formatted_date);

// If user data or registration date is not available, return a message
return __('Member since information not available', 'your-text-domain');

} add_shortcode('vendor_member_since', 'vendor_member_since_shortcode');


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.