Adding current user’s ID to the end of PDF hyperlinks in post content

Here’s a solution that I came up with that will add the user query argument and the current user’s ID to PDF links, e.g.: http://mysite/wp-content/uploads/2018/12/My_PDF_File.pdf?user=54 This code works by inspecting the post’s content using the the_content filter, then parsing the content using DOMDocument. I’ve run into various gotchas using DOMDocument and much of this code … Read more

How to tell whether a user meta value has increased or decreased [closed]

I would solve this creating two extra Custom Fields: _score_last _score_variation The first underscore makes the CF invisible in the Admin area. Drop the following code in your theme’s functions.php: if( is_admin() ) { add_action( ‘save_post’, ‘wpse_57217_check_customfield_variation’, 11, 2 ); } function wpse_57217_check_customfield_variation( $post_id, $post ) { if ( ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE … Read more

Get the Google+ and Twitter links – WordPress SEO plugin

I found a way to do it in author.php file Just use the following to display the Google+ and Twitter links: <?php $curauth = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author)); echo $curauth->googleplus; echo $curauth->twitter; ?>

Store user’s registration date as meta

In your case $registered is the user id not the user object so it does not work. Please use the code as given below. add_action( ‘user_register’, ‘set_user_registration_date’, 10, 1 ); function set_user_registration_date( $user_id ) { $user = get_userdata ( $user_id ); // Update the registration meta data update_user_meta ( $user_id, ‘registration_date’, $user->user_registered ); }

Is a user_meta research case-sensitive or not

Solution found : to make a case-sensitive search for a meta_key / meta_value pair : a hardcoded mysql query on the usermeta table with the BINARY keyword, with get_results() method of $wpdb object: global $wpdb; $sql = $wpdb->prepare( “SELECT user_id FROM {$wpdb->prefix}usermeta WHERE meta_key = ‘unique_id’ AND BINARY meta_value=”unique_id_value””); $wordpress_user_query = $wpdb->get_results( $sql);

How to display current_user bio

You probably want to use wp_get_current_user to find out which user is browsing the site. $current_user = wp_get_current_user(); echo ‘User ID: ‘ . $current_user->ID . ‘<br />’; From there you’ll use the ID to pull the user’s metadata with get_user_meta. $all_meta_for_user = get_user_meta( $current_user->ID ); echo ‘User Description: ‘ . $all_meta_for_user[‘description’] . ‘<br />’; The … Read more

Update user meta through a front end form

There are 3 main issues in your code: I see you’re using current_user_id() which does not exist in WordPress, so I believe that should be get_current_user_id(). Your update_basic_user_meta() function basically would work in updating the user’s metadata, but you need to check whether the POST data (gender and specialty) are actually set before proceeding to … Read more

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