Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    This code in child-theme functions.php adds a new tab in profile and then content to that tab.
    When it is about the user himself it opens on edit mode and the user meta field description appears in a form field ready for editing

    Maybe you need something like that

    I hope if you have a look on that will help

    Regards

    NIkos

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    * Add a new Profile tab
    * @param array $tabs
    * @return array
    */
    function um_mycustomtab_add_tab( $tabs ) {

    /**
    * You could set the default privacy for custom tab.
    * There are values for ‘default_privacy’ atribute:
    * 0 – Anyone,
    * 1 – Guests only,
    * 2 – Members only,
    * 3 – Only the owner
    */
    $tabs[ ‘mycustomtab’ ] = array(
    ‘name’ => ‘About’,
    ‘icon’ => ‘um-faicon-user’,
    ‘default_privacy’ => 2,
    );

    UM()->options()->options[ ‘profile_tab_’ . ‘mycustomtab’ ] = true;

    return $tabs;
    }
    add_filter( ‘um_profile_tabs’, ‘um_mycustomtab_add_tab’, 1000 );

    /**
    * Render tab content
    * @param array $args
    */
    function um_profile_content_mycustomtab_default( $args ) {

    $action = ‘mycustomtab’;
    $fields_metakey = array(
    ‘description’
    ,’author_facebook’,
    );

    $nonce = filter_input( INPUT_POST, ‘_wpnonce’ );
    if( $nonce && wp_verify_nonce( $nonce, $action ) && um_is_myprofile() ) {
    foreach( $fields_metakey as $metakey ) {
    update_user_meta( um_profile_id(), $metakey, filter_input( INPUT_POST, $metakey ) );
    }
    UM()->user()->remove_cache( um_profile_id() );
    }

    $fields = UM()->builtin()->get_specific_fields( implode( ‘,’, $fields_metakey ) );
    ?>

    <div class=”um”>
    <div class=”um-form”>
    <form method=”post”>

    <?php
    if( um_is_myprofile() ) {
    foreach( $fields as $key => $data ) {
    echo UM()->fields()->edit_field( $key, $data );
    }
    }
    else {
    foreach( $fields as $key => $data ) {
    echo UM()->fields()->view_field( $key, $data );
    }
    }
    ?>

    <?php if( um_is_myprofile() ) : ?>
    <div class=”um-col-alt”>
    <div class=”um-left”>
    <?php wp_nonce_field( $action ); ?>
    <input type=”submit” value=”<?php esc_attr_e( ‘Update’, ‘ultimate-member’ ); ?>” class=”um-button” />
    </div>
    </div>
    <?php endif; ?>

    </form>
    </div>
    </div>

    <?php
    }
    add_action( ‘um_profile_content_mycustomtab_default’, ‘um_profile_content_mycustomtab_default’ );

    • This reply was modified 4 years, 6 months ago by wpnikos.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @captaind

    You can try this tutorial in the link: Ultimate Member – Dynamically populate form fields from URL Parameter

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to retrieve User Data from Ultimate Member plugin’ is closed to new replies.