WordPress.org

Ready to get started?Download WordPress

Forums

Cimy User Extra Fields
[resolved] How to recover fields value to put them into page or post? (9 posts)

  1. bluedarike
    Member
    Posted 2 years ago #

    Hi,
    All are in the title. I want to create a page with some fields with the current user value in them. Fields are on text and dropdown type.

    Can someone help me please?

    Sorry for my spelling mistake.

    http://wordpress.org/extend/plugins/cimy-user-extra-fields/

  2. DonnaNJ
    Member
    Posted 1 year ago #

    $contactaddy1 = get_cimyFieldValue($authorID, 'CONTACTADDY1');
    $contactphone = get_cimyFieldValue($authorID, 'CONTACTPHONE');

    does this help ?

  3. binga30
    Member
    Posted 1 year ago #

    My field does display on the user profile in the dashboard but not on the profile page on the site.

    Here is how I am trying to output a field called PHONENUMBER:

    <div class="details_fields">
    <label for="email"><?php echo SPEC($GLOBALS['_LANG']['_tpl_myaccount27']) ?></label>
    <input type="text" name="cimy_uef_PHONENUMBER" value="<?php get_user_meta($user_id,'cimy_uef_PHONENUMBER',true);?>" class="short right20" /><br />
    </div>

    Any tips appreciated

  4. binga30
    Member
    Posted 1 year ago #

    Here is the line I needed for the value:

    echo get_cimyFieldValue($userdata->ID, 'PHONENUMBER'); ?>

    However this only displays the value and does not let me change it upon submit?

  5. Marco Cimmino
    Member
    Plugin Author

    Posted 1 year ago #

    How about starting to read the documentation I wrote?

  6. jsims281
    Member
    Posted 1 year ago #

    I'm looking at the documentation and all I can see is that set_cimyFieldValue returns false if the value is already set.

    Is there a way to update a cimyFieldValue that has already been set?

    USAGE:

    $result = set_cimyFieldValue($user_id, $field_name, $field_value);

    RETURNED VALUE:
    An array is returned with all user ids where the change has been successful; empty array in case of error or the value is already in the DB.

  7. jsims281
    Member
    Posted 1 year ago #

    I wrote a couple of queries to do this manually in the end:

    $field_id = $wpdb->get_var(
        "
        SELECT ID
        FROM wp_cimy_uef_fields
        WHERE NAME = '$field_name'
        "
    );
    $update_status = $wpdb->update(
        'wp_cimy_uef_data', //table name
        array(
            'value' => $wpdb->escape($field_value)//value to update
        ),
        array(
            'field_id' => $field_id, //where clause
            'user_id' => $user_id
        )
    );

    This should let you update a cimy field using the field name and the user id.

  8. Marco Cimmino
    Member
    Plugin Author

    Posted 1 year ago #

    I'm looking at the documentation and all I can see is that set_cimyFieldValue returns false if the value is already set.

    It works perfectly if you have or not a value set.
    Unless you describe a use case where I can reproduce the issue, for now I cannot.

  9. Marco Cimmino
    Member
    Plugin Author

    Posted 1 year ago #

    This should let you update a cimy field using the field name and the user id.

    Your code works only for text and textarea[-rich] fields, it will save garbage for other fields.
    I discourage to use this buggy code (also unsafe since it doesn't escape properly field's name, and has 'wp_' hard coded, which is also wrong) and encourage to read the documentation and file proper issues with steps when it doesn't work, adding the code used.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.