Getting User Birthday with Component

jake pavek Posted in Component Development 4 months ago

Hello I was curious how I would get a users birthday. I tried this to practice:

$birthday = ossn_loggedin_user()->birthdate; 
echo '<h2>Your Brithday (' . $birthday . ')</h2>';

this did not work tho.

Replies
us Jake pavek Replied 4 months ago

I got it!

Okay I got it finally.

us Jake pavek Replied 4 months ago

I have no idea honestly where it will show, I'm just trying to follow the component guide and doing something simple like telling the user what his birthday is

    <?php
    function horoscope_init() {
        ossn_register_callback('ossn', 'init', 'horoscope_init');

        // Register an action to display the horoscope
        ossn_register_action('horoscope/display', __DIR__ . '/actions/display.php');

        // Register languages
        ossn_register_languages('en', __DIR__ . '/locale/ossn.en.php');
    }

// Your logic for getting the user's birthday, determining zodiac sign, and fetching horoscope
// ...

// Example action file content (create /components/horoscope/actions/display.php):
// See the next code snippet for the action file content.

It's for a daily horoscope plugin I plan on either getting developed or developing.

Then for display I have this

<?php
// components/horoscope/actions/display.php
$guid = ossn_loggedin_user()

$birthday = ossn_loggedin_user()->birthdate; // Implement the function to get user's birthday
//$zodiac_sign = determine_zodiac_sign($birthday); // Implement the function to determine zodiac sign
//$horoscope = fetch_horoscope($zodiac_sign); // Implement the function to fetch horoscope from API

echo '<h2>Your Brithday (' . $birthday . ')</h2>';
echo '<p>' . $horoscope . '</p>';
Indonesian Arsalan Shah Replied 4 months ago

Hello Jake, on which page you are trying to show birthdate. The birthdate variable seems correct? when you run this code user is loggedin or not?