Getting different user data depending on where I use variable

I’ve only seen some parts of your code, but I guess I know where the problem lies… If this is what you’re printing in the loop: <script type=”text/javascript”> jQuery(document).ready(function($) { $(‘.callback’).val(‘<?php echo $user->first_name; ?> <?php echo $user->last_name; ?>’); }); </script> <?php echo do_shortcode( ‘[contact-form-7 id=”12345″]’ ); ?> And you want to output multiple forms on … Read more

How to exclude posts for current user

I’m not entirely sure what the problem is, because you’ve already mentioned all the tools that you need to solve it… Just use pre_get_posts filter, check if the user is logged in, get the IDs of posts he should not see and exclude them in query: function remove_some_posts_for_user( $query ) { if ( ! is_admin() … Read more

Send admin new order email to logged in user as well

What you have makes sense, except that your variable names dont match. You have $object in your function definition and in the function code you are trying to use $order. Adjusted: /* SEND ADMIN E-MAIL TO LOGGED IN USER */ /* — */ add_filter( ‘woocommerce_email_recipient_new_order’, ‘your_email_recipient_filter_function’, 10, 2); /* Add parents e-mail address to new … Read more

get_user_meta() in multiste with respect to subdomain

You could catch and store the data separately on a per blog basis by filtering the user meta update call, via the update_user_metadata filter… function myplugin_init() { add_filter( ‘update_user_metadata’, ‘myplugin_update_points’, 10, 5 ); } function myplugin_update_points( $null, $object_id, $meta_key, $meta_value, $prev_value ) { if ($meta_key == ‘qa_point’) { remove_filter( ‘update_user_metadata’, ‘myplugin_update_points’, 10, 5 ); global … Read more

Shortcode for Listing Users from Meta Value?

It’s a small coding mistake.. It’s not displaying anything because when there are results, the end output is always a </ul> because you’re always overwriting the $results and not appending output to the variable: $results=”<ul>”; foreach ($users as $user){ $results=”<li>” . $user->display_name . ‘</li>’; } $results=”</ul>”; So the proper code is: $results=”<ul>”; foreach ($users as … Read more

Add custom user meta data

Adding custom field to all existing users. You will have to get the list of users and then, in a loop, set a custom field for each of them. $users = get_users( [ ‘fields’ => ‘id’, ‘meta_key’ => ‘YOUR_META_KEY’, ‘meta_compare’ => ‘NOT EXISTS’ ] ); if ( is_array($users) && count($users) ) { $meta_value = false; … Read more

Update a user profile via frontend

I’ve written this in a hurry and it’s untested and probably sloppy code, but it gives you an idea of how to accomplish this with AJAX. <form id=”update_user”> <div class=”form-group”> <label for=”firstname”>Name</label> <input type=”text” name=”firstname” id=”firstname” value=”<?= esc_attr(wp_get_current_user()->user_firstname) ?>” placeholder=”Vorname”> </div> <div class=”form-group”> <label for=”name”>Name</label> <input type=”text” name=”name” id=”name” value=”<?= esc_attr(wp_get_current_user()->user_lastname) ?>” placeholder=”Name”> </div> <div … Read more

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