Skip to:
Content
Pages
Categories
Search
Top
Bottom

Set Birthday value buddypress


  • Thagintoki
    Participant

    @thagintoki

    Hi and thanks for reading my question, I have been trying to create a default data for buddypress and I am stuck, Searched about 2 days in forums but no clue. Here is the code I use:

    <?php
                        $randDate = mt_rand(0062055681,0562055681);
                        $randDate = date('Y-d-m H:m:s', $randDate);
                        echo $randDate.'<br>';
                        xprofile_set_field_data( 1, $random_user, $displayname );
                        xprofile_set_field_data( 3, $random_user, 'Man' );
                        xprofile_set_field_data( 6, $random_user, 'Woman' );
                        xprofile_set_field_data( 9, $random_user, 'Single' );
                        xprofile_set_field_data( 17, $random_user, $city );
                        xprofile_set_field_data( 18, $random_user, $country );
                        xprofile_set_field_data( 2, $user_id, $randDate );
    ?>

    everything works fine except for the datebox field which is field number (2); Thanks for helping.

Viewing 14 replies - 1 through 14 (of 14 total)

  • Henry Wright
    Moderator

    @henrywright

    How are you getting $user_id? You should show us all of your code. My advice is to dump stuff to check where you’re going wrong. For example:

    var_dump( $user_id );
    var_dump( $randDate );

    Thagintoki
    Participant

    @thagintoki

    $random_user = wp_insert_user( $userdata ) ;

    this is how i get the user ID its working fine only birthday and avatar which are my problem, I can’t set a date or an avatar from an external link.
    I have used an API to generate random users then I save it as a buddypress user.
    And $user_id was a mistake I use instead $random_user but it’s not working anyways.


    Henry Wright
    Moderator

    @henrywright

    What did you get when you used var_dump()?


    Thagintoki
    Participant

    @thagintoki

    the user ID and DATE, works fine


    Henry Wright
    Moderator

    @henrywright

    Have you checked in the db to make sure the profile data has been set? The issue could be how you’re displaying it at the front-end.


    Thagintoki
    Participant

    @thagintoki

    yes checked the DB and I can see my users with all data except birthday and avatar that’s all


    Henry Wright
    Moderator

    @henrywright

    In that case, I think your code should be working. The problem is most probably elsewhere.


    Thagintoki
    Participant

    @thagintoki

    all i want to know is how the avatar are set in the user meta, because I have an external image url and want to set it in the meta but don’t know how they do it in buddypress, i have red all the files in buddypress plugin, but nothing helps. For the field datebox also I don’t know why it is not working I am sure my data is good but why it is not showing ?


    shanebp
    Moderator

    @shanebp

    i have red all the files in buddypress plugin

    Then you know that BP does not store any data re individual avatars in the database.


    Thagintoki
    Participant

    @thagintoki

    he store its link in the meta, but don’t know which function should I use as I couldn’t find any, for datebox I used the right function yet not stored, why?


    Henry Wright
    Moderator

    @henrywright

    all i want to know is how the avatar are set in the user meta

    Is this related to the datebox stuff, or separate?


    Thagintoki
    Participant

    @thagintoki

    separated sorry, but the birthday (datebox) still not working


    Thagintoki
    Participant

    @thagintoki

    anyone got an idea?


    Matt2012
    Participant

    @matt2012

    I spent a lot of time on a similar issue and the only thing that worked was using this format.

    date(“Y-m-d 00:00:00”)

    In other words must have h:i:s but they must be zeros. That seems like a bug to me but thats the only thing that worked with a buddypress date field whilst using xprofile_set_field_data

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.
Skip to toolbar