Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating xProfiles using functions.php

  • @hardeepasrani

    Participant

    I wanted to create a function which will automatically add a xProfile field. Is it possible to do it using a custom plugin or functions.php?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @shanebp

    Moderator

    Yes.
    Start by taking a look at :

    function xprofile_insert_field() in bp-xprofile\bp-xprofile-functions.php

    @hardeepasrani

    Participant

    Thanks for passing the info 🙂

    @hardeepasrani

    Participant

    I used the following code, and it’s not doing the job:

    function field_xprofile_twitter()
    {
    
    $group_args = array(
         'name' => 'Social Networks'
         );
    $group_id = xprofile_insert_field_group( $group_args ); // group's ID
    
    xprofile_insert_field(
        array (
               field_group_id  => $group_id,
               name            => 'Twitter',
               can_delete      => false,
               field_order  => 1,
               is_required     => false,
               type            => 'textbox'
        )
    );
    }

    Hope you can help 🙂

    @shanebp

    Moderator

    Are you sure group_id is being set?

    Take another look at :
    function xprofile_insert_field() in bp-xprofile\bp-xprofile-functions.php

    Try passing an array to $args for xprofile_insert_field
    Like you did with xprofile_insert_field_group

    $args = your array;

    xprofile_insert_field( $args );

    @hardeepasrani

    Participant

    This isn’t doing the job either:

    function field_xprofile_twitter()
    {
    
    $group_args = array(
         'name' => 'Social Networks'
         );
    $group_id = xprofile_insert_field_group( $group_args ); // group's ID
    
    xprofile_insert_field( $xfield_args );
    $xfield_args =  array (
               field_group_id  => $group_id,
               name            => 'Twitter',
               can_delete      => false,
               field_order  => 1,
               is_required     => false,
               type            => 'textbox'
        );
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Creating xProfiles using functions.php’ is closed to new replies.
Skip to toolbar