Solving a get_user_meta() problem in Multisite

The problem is that the idea of “the user of a specific subdirectory” doesn’t really exist natively in WP. There are sites (“subdirectories”), and there are users, and users can be associated with sites (through Roles and Capabilities), but there is no guarantee of a one-to-one correspondence. If you are running a network where users … Read more

editing usermeta when field is an array

This code is your problem: $s2_custom=get_user_meta($u->ID, ‘wp_s2member_custom_fields’); $real = $s2_custom[0]; $real[‘loomsong_del’]=’email’; update_user_meta($u->ID, ‘wp_s2member_custom_fields’,$real); get_user_meta returns an array of the meta values. Since in this case there’s only a single value with the array, you need to pass the single parameter to it. Try this: $s2_custom=get_user_meta($u->ID, ‘wp_s2member_custom_fields’, true); $s2_custom[‘loomsong_del’]=’email’; update_user_meta($u->ID, ‘wp_s2member_custom_fields’,$s2_custom); This won’t fix your already … Read more

get_the_author_meta not working

In the “homepage” code you posted, you have get_the_author_meta commented out. <?php /*?><img src=”https://wordpress.stackexchange.com/questions/77403/<?php echo esc_attr( get_the_author_meta(“author_pic_sidebar’, $user->ID ) ); ?>” alt=”” /><?php */?> That is why it doesn’t work. See that <php /*?> right at the beginning of the line?

How to add to a user_meta field (append)

Use get_user_meta(): $original = get_user_meta( $user->ID, ‘purchase_history’, TRUE ); echo $original . ‘ Pancake Breakfast 05/15/2005’; To update the value use update_user_meta(): update_user_meta( $user->ID, ‘purchase_history’, $original . ‘Pancake Breakfast 05/15/2005’ );

Countdown to date function?

You can use the following function to display it <?php function days_to_go(){ $datetime1 = new DateTime(‘2013-3-2’);//Pass resignation date as a parameter. $datetime2 = new DateTime(now); $interval = $datetime1->diff($datetime2); echo $interval->format(‘%a days to go’); } ?> For more information on date_diff function see this page.

Test if key is in user_meta array

First of all, I believe your syntax is incorrect. Should be: $group = ‘_mm_group_membership’; // key should be a string Secondly, did you try using $u->get? Here’s what the doc says: If fields is set to all_with_meta, it will return an array of WP_User objects. So yes, if you specified this parameter you should get … Read more

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