Multisite – Echo admins profile meta

According to the Codex, get_user_id_from_string() is deprecated, and should be replaced with get_user_by(). <p> <?php $thisblog = get_current_blog_id(); // probably don’t need this anymore $admin_email = trim( get_option( ‘admin_email’ ) ); $admin_user = get_user_by( ’email’, $admin_email ) ); $phone_number = get_user_meta($admin_user->ID, ‘phone’, true); if($phone_number!=”) { ?> <?php echo $phone_number; ?> <?php } else { ?> … Read more

Conditionally process comments while ignoring replies

Simply check if the comment has a parent before decrementing points. Reading the Codex entry for the get_comment() function, you’ll note that in the manner you use the function you will be returned an object containing keys that correspond to the column names of the wp_comments table. Viewing the wp_comments scehma, note that there is … Read more

WP Cron: Save third party data as user meta

An alternative way to do what I wanted : Save the time when the action has been ran and check the difference with actual time : function my_save_statistiques( $user_id ) { $user_id = get_current_user_id(); $current_time = time(); if (empty($current_time)) { update_usermeta( $user_id, ‘last_analytics’, $current_time ); } $last_analytics = get_user_meta( $user_id, ‘last_analytics’, true ); $diff = … Read more

How to delete user meta by key

You’re data is stored in a serialized array in the database, per a comment to the question: … it’s stored as the api’s working for. It looks like that in the database : `a:3:{i:0;a:1:{s:5:”titre”;s:3:”sfg”;}i:1;a:1:{s:5:”titre”;s:4:”test”;}i:2;a:1:{s‌​:5:”titre”;s:4:”test”;}}` You are trying to remove only part of that serialized array by passing the key to delete_user_meta(). That is not how … Read more

Store Foreach in user profile

Your problem is here: $my_graph =. At every iteration you are resetting the entire string to a new value. You need $my_graph .= — notice the .— to concatenate a string together. That is a PHP syntax problem. I don’t think I would do it this way though. update_usermeta() will serialize an array or object … Read more

Hide user fields based off capability

This filter needs to return something. Try this function modify_contact_methods($profile_fields) { if(current_user_can(‘edit_users’)) { // Field addition and removal will be done here // Add new fields $profile_fields[‘company_name’] = ‘Company Name’; $profile_fields[‘company_id’] = ‘Company ID’; } return $profile_fields; } add_filter(‘user_contactmethods’, ‘modify_contact_methods’);

WordPress Author Information show paragraph?

Use wpautop() https://codex.wordpress.org/Function_Reference/wpautop Example <?php ///MUST BE IN A LOOP echo wpautop(get_the_author()); ///MUST BE IN A LOOP ?> So you will need to find out where author name are being displayed in the code. Normally the default file is author.php