• Resolved Houdini

    (@romariokg)


    Hello. In the author-content.php file there is code: <?php echo esc_html($author->description); ?> But there is no User Descriptions field in the account editing form! I needed this field, how can I add it?

    I added the code to the form:

    <div class="rtcl-form-group">
    <label for="rtcl-description" class="rtcl-field-label">
    <?php esc_html_e( 'User Description', 'classified-listing' ); ?>
    </label>
    <div class="rtcl-field-col">
    <textarea name="description" id="rtcl-description" class="rtcl-form-control"><?php echo esc_textarea( get_user_meta( $user->ID, 'description', true ) ); ?></textarea>
    </div>
    </div>

    But the text that I enter into this field is not saved when I click update account and does not appear on the ad owner page.

    If I enter text directly through the admin panel into the user’s profile, it is displayed. how to fix it?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    That the key for author bio but right now no option to save it from frontend. User can add it from admin dashboard user profile. If you want to add the field, you can modify myaccount/form-edit-account.php file and also have to save it for usermeta and that meta key is ‘description’

    Thank you

    Thread Starter Houdini

    (@romariokg)

    Hello. Thanks! I made a working version of the code, I’ll leave it here, it might be useful to someone!

    In the location you need in the myaccount/form-edit-account.php file, paste the following code:

    <div class="rtcl-form-group">
    <label for="rtcl-description" class="rtcl-field-label">
    <?php esc_html_e( 'User Description', 'classified-listing' ); ?>
    </label>
    <div class="rtcl-field-col">
    <textarea name="description" id="rtcl-description" class="rtcl-form-control"
    style="width: 100%; min-height: 150px;">
    <?php echo esc_textarea( get_user_meta( $user->ID, 'description', true ) ); ?>
    </textarea>
    </div>
    </div>

    To save text in user metadata from the frontend, paste the following code into the function.php file:

    // Saving a user description
    function save_user_description( $user_id ) {
    // Checking for user rights
    if ( ! current_user_can( 'edit_user', $user_id ) ) {
    return;
    }

    // Save the description
    if ( isset( $_POST['description'] ) ) {
    // Clear the input and save it in the metafield
    update_user_meta( $user_id, 'description', sanitize_textarea_field( $_POST['description'] ) );
    }
    }
    add_action( 'personal_options_update', 'save_user_description' );
    add_action( 'edit_user_profile_update', 'save_user_description' );
    add_action( 'profile_update', 'save_user_description' ); // Added profile update hook

    Now on the ad author’s page there will be text from the descriptions. <?php echo esc_html($author->description); ?>

    • This reply was modified 1 month, 2 weeks ago by Houdini.
    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Thanks for sharing the code.

    Thread Starter Houdini

    (@romariokg)

    My pleasure! Glad to cooperate!

    Thank you for answering quickly!

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