Updating user meta on save post

You could query all the authors and loop through to update their dates. The below query pulls all users who have a programme_id of the current post_id and allocates an array of their IDs. You can then loop through to update whatever is necessary: /** Save Custom Metaboxes **/ function save_custom_meta_boxes( $post_id, $post ) { … Read more

Show global Message in User Profiles with admin only Input field in WordPress Backend

You just need to move the capability check “inwards”: function wpse_230369_quote_of_the_day( $user ) { $quote = esc_attr( get_option( ‘quote_of_the_day’ ) ); ?> <div class=”visible-only-for-admin”> <h3>Quote of the Day Input Field</h3> <table class=”form-table” > <tr> <th><label for=”quote_of_the_day”>Quote of the Day</label></th> <td> <?php if ( current_user_can( ‘administrator’ ) ) : ?> <input type=”text” name=”quote_of_the_day” value=”<?php echo $quote … Read more

wordpress meta value compare between two date

After some research on wp codex I found my solution. Here I have to change birth_date format during save. I saved value like yy-mm-dd this format and changed my meta_query Here is the code $studentdata = get_users( array( ‘meta_query’=> array( array( ‘key’ => ‘birth_date’, ‘value’ => array( $startyear.’-01-01′,$endyear.’-12-31′), ‘compare’ => ‘BETWEEN’, ) ), ‘role’=>’student’ ) … Read more

How to update user profile custom fields

I use update_user_meta to update the fields. You can add this in functions.php of your child theme. function save_extra_user_profile_fields( $user_id ) { if ( !current_user_can( ‘edit_user’, $user_id ) ) { return false; } update_user_meta( $user_id, ‘telephone’, $_POST[‘telephone’] ); } add_action( ‘personal_options_update’, ‘save_extra_user_profile_fields’ ); add_action( ‘edit_user_profile_update’, ‘save_extra_user_profile_fields’ );

I cannot find the difference between these wp_capabilities values in wp_usermeta

You’ve posted some serialized arrays. The first entry, a:1:{s:13:”administrator”;s:1;} is corrupted – that’s not a valid serialized array. The second entry, a:1:{s:13:”administrator”;s:1:”1″;} looks like this when unserialized: array ( ‘administrator’ => ‘1’, ) The third entry, a:1:{s:13:”administrator”;b:1;} looks like this when unserialized: array ( ‘administrator’ => true, ) In my setup, capabilities are stored like … Read more

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