0

I have solution with js that click on the Collapse button, but this is no good solution. I want to make this work true DB with php code.

I found that the table who hold this value is wp_usermeta. Then there is a column [meta_key] that hold: user-settings and there is column meta_value that hold values for example: mfold=o&editor=tinymce&libraryContent=browse&ed_size=465.

The value that I need is mfold=o so I want to check

if "mfold" not exsist then add mfold=1, else check if mfold=o update to mfold=1

I've tried to play with

<?php get_user_meta($user_id, $key, $single);  ?>

and

<?php update_user_meta( $user_id, $meta_key, $meta_value, $prev_value ); ?>

but without luck

  • Two request, this is not your first question, please work on your formatting so that others don't have to clean your mess. Also, please revisit all your previous questions, and accept answers where appropriate, otherwise leave constructive feedback if necessary. Please see help center and visit the tour page to learn how this site operates – Pieter Goosen Oct 27 '14 at 17:45
0

To make the admin sidebar menu always be collapsed, try adding the following code in the functions.php file of your child theme, or add it in your site using a plugin like Code Snippets, or Add Actions and Filters.

global $user_ID;
$user_fold = get_user_meta( $user_ID, 'wp_user-settings', true );
$exp_array = explode( "&", $user_fold );
$search_array = array_search( "mfold=o", $exp_array );
if ( $search_array ) {
    $exp_array[ $search_array ] = "mfold=f";
    $exp_array = implode( "&", $exp_array );
    update_user_meta( $user_ID, 'wp_user-settings', $exp_array );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.