How can I track who clicked what in my member area?
How can I track who clicked what in my member area?
How can I track who clicked what in my member area?
@WebElaine is correct. I had to use the wp_get_current_user(); and remove global. This is what worked for me function download_to_wallet() { $current_user = wp_get_current_user(); // get current user’s information $qr_url = $current_user->qrbase_code_pass_url; return ‘<a href=”‘. $qr_url . ‘”><img class=”qr_download” src=”https://example.com/wp-content/uploads/2018/08/add-to-apple-wallet-logo.png” style=”width:200px;”></a>’; }
(Updated/new answer) How to make it show “United States (US)” instead, on the frontend, in a shortcode? First off, you got united-states (the country slug/key) instead of United States (US) (the country name) because your extrainfo_save_extra_user_profile_fields() function is saving the country slug/key instead of the country name. That’s not a problem, and I’d do the … Read more
There are “month_of_birth“, “day_of_birth“, “year_of_birth“. How to store them in one meta key (‘birth_date‘) ? If you mean to replace all the three meta keys with one single meta key, then you can save the birth_date meta as an array, so that the value would be something like this: array( ‘month’ => ‘august’, ‘day’ => … Read more
Add another role to a user when they click a button?
Classic case of = instead of ==, ie. you’re assigning values in a conditional statement, which always resolves to true: if ( $need == “Option A”) { get_template_part(‘front/option-a’); }
wp_get_current_user() does not return all the data for the user, you should try using get_user_meta(). Try as below $company = get_user_meta($current_user->ID,’company’); $mf_group = get_user_meta($current_user->ID,’mf_group’); and in your post loop changes this two lines as below ‘company’ => $company[0], ‘mf_group’ => $mf_group[0], Hope this helps.
You would need to use a meta query for this. $meta_query_args = array( array( ‘key’ => ‘access_code’, ‘value’ => ‘abc’, ‘compare’ => ‘=’ ) ); $args = array( ‘meta_query’ => $meta_query_args ); $users = get_users( $args ); // User Loop foreach ( $users as $user ) { update_user_meta( $user->ID, ‘association’, ‘XYZ Corporation’); }
Your loop rewrite is good so far, yet you can make it better: <?php $at_social_html=”<ul class=”at__social”>”; /* array elements: social-media-name/meta-key => [‘href-before-string’, ‘href-after-string’, ‘fa-class’] */ $author_sociables = array( ‘facebook’ => [”, ”, ‘fa-fb’], ‘twitter’ => [”, ”, ‘fa-twitter’], ‘instagram’ => [”, ”, ‘fa-instagram’], ‘google’ => [‘//plus.google.com/’, ”, ‘fa-google-plus’], ‘pinterest’ => [‘//pinterest.com/’, ”, ‘fa-pinterest’], ‘tumblr’ => … Read more
I did manage to figure out a solution. It’s not pure MySQL, but rather uses some WP/PHP wizardry. So this is how I solved the problem – but I’m still open to better solutions (particularly a pure MySQL method). I used the $wpdb->get_results() object method to retrieve the results of the SQL query. That returns … Read more