delete_user_meta Delete one value out of array

Thanks yo Howdy_McGee, Here is working code. // Remove favorite authors from current users DB function fav_author_remove_user(){ check_ajax_referer( ‘fav_authors_obj_ajax’, ‘security’ ); $remove_this_author = $_POST[‘clicked_author_id’]; if ( current_user_can( ‘edit_posts’ ) ){ $user_id = fav_authors_get_user_id(); $author_list = get_user_meta( $user_id, FAV_AUTHORS_META_KEY, true ); //print_r($author_list); $author_saved = array_search($remove_this_author, $author_list); if( FALSE !== $author_saved ){ // Remove $author_saved unset($author_list[$author_saved]); $author_arr … Read more

How can I sort get_users() by any value (last_name, user defined fields and more)

get_users() does not allow you to directly sort by whatever you like, but there are ways around it. The Codex for get_users() says: orderby – Sort by ‘ID’, ‘login’, ‘nicename’, ’email’, ‘url’, ‘registered’, ‘display_name’, ‘post_count’, ‘include’, or ‘meta_value’ (query must also contain a ‘meta_key’ – see WP_User_Query). meta_value is a very powerful way to go … Read more

Show a list of recently viewed posts to a user

This plugin may fulfill your requirements. http://wordpress.org/extend/plugins/recently-viewed-posts Usage get_recently_viewed_posts( $max_shown = 10 ) returns a string of li’s. recently_viewed_posts( $max_shown = 10 ) prints a div If you are interested in learning how to develop this functionality yourself, download the plugin and see the source files. WordPress is Open Source! Update: The above plugin did … Read more

Extra User Profile Field Upload File / Image

PHP CODE /* * Load style & scripts */ function itclanbd_admin_load_scripts( $hook ) { $allowed = [‘profile.php’, ‘user-new.php’, ‘user-edit.php’]; if ( ! in_array( $hook, $allowed ) ) { return; } wp_enqueue_media(); wp_enqueue_style(‘finance2sell’, plugins_url(‘css/style.css’, __FILE__), array(), null); wp_enqueue_script(‘finance2sell’, plugins_url(‘js/scripts.js’, __FILE__), array(), ‘1.3’, true); } add_action( ‘admin_enqueue_scripts’, ‘itclanbd_admin_load_scripts’ ); /** * Create custom fields * @param $user … Read more

Are the default entries for a user in wp_usermeta documented?

You may want to take a look at the code itself: https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/user.php#L1376 The above links to a documented list of the meta generated when WordPress generates a new user in the wp_create_user function. From these comments I pulled a quick list: user_pass, user_login, user_nicename, user_url, user_email, display_name, nickname, first_name, last_name, description, rich_editing, comment_shortcuts, admin_color, use_ssl, … Read more

How to Make admin Sidebar Menu always be Collapse by code

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 … Read more

Customizing WP tables or adding new ones?

You should avoid adding new tables or customising the existing tables to add fields for users. If you want to store a phone number etc, do it using user meta: add_user_meta( $user_id, ‘riccardo_phone_number’, ‘0123-456-7890’ ); …. $phone_number = get_user_meta( $user_id ); User meta is a key and a value with a post ID in the … Read more

How to pre-fill Google Forms URLs with logged-in WordPress user’s data

AS easy as you said: $user = wp_get_current_user(); if(!empty($user)) { $email = $user->user_email; $fname = $user->user_firstname; $sname = $user->user_lastname; $url=”https://docs.google.com/forms/d/e/1FAIpQLSeChqhovV70FbILIlfeo8K5UL9q3hfjPkngEe4IJkXMmCbawg/viewform?entry.646601418=STUDENT+01&entry.280532864=”.$email.’&entry.1176284616=’.$fname.’&entry.165661554=’.$sname; echo $url; } else { $email=”[email protected]”; $url=”https://docs.google.com/forms/d/e/1FAIpQLSeChqhovV70FbILIlfeo8K5UL9q3hfjPkngEe4IJkXMmCbawg/viewform?entry.646601418=STUDENT+01&entry.280532864=”.$email.’&entry.1176284616=First&entry.165661554=Last’; echo $url; } If the user is logged in (if !empty ($user) ) then it grabs the data from the user variable wp_get_current_user, we could also wrap in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)