Tag Info

Hot answers tagged

4

There is no one answer, because both have pros and cons depending on what you want to store and why. A (probably non-exhaustive) list of differences to consider for a choice: Capabilities are designed to check if a user can do something or not. user_can and current_user_can are there to help you to check user permissions. You can implement that with user ...


3

I have tested your code on my side, and it works perfectly. The relevant info displays, whether I'm logged in or not. This is definitely not a problem with your code, but more an external problem. You will need to look for any type of code that might restrict this code from showing if a user is logged out, something like if ( is_user_logged_in() ). If you ...


2

If you check out the documentation for the update_user_meta() function, you'll note that the $meta_value parameter already accepts objects and arrays, so you can simply save a user's positions in an array without any additional effort: update_user_meta( 22, 'position_names', array( 'Khaleesi of the Great Grass Sea', 'Breaker of ...


2

Maybe start searching for plugins like Wishlist-Member, its description will give you the jargon and wordpress-specific ideas you'll need to better refine your search and move forward in your solution.


2

Your code does work. It's just that you are declaring $xfield_args after you have made the call xprofile_insert_field( $xfield_args ); it should look like this add_action('bp_init', 'field_xprofile_twitter'); function field_xprofile_twitter() { global $bp; $xfield_args = array ( field_group_id => 1, name => ...


2

I believe Crazycoolcam spelled the table incorrectly, user_meta vs usermeta. You may also want to define the else case, what happens if the table is not user. Try this: <?php $wpdb->add_database(array( //Connect to Users Database 'host' => DB_HOST, // I am using the same host for my two DBs 'user' => DB_USER, ...


2

You can just call get_user_meta without specifying a key, and it will return all MetaValues for the user. $userdata = get_user_meta( $userID ); You may have to do a mapping for displaytitles of the Metavalue, as they are returned in an array, where the keys are the databasevalues of your metakeys. For example, you may get ...


2

This is not a simple answer, so first you will need to include one more filter to allow you to grab both the make the meta_query interact with the main query via an OR instead of a AND, check my sample of code: add_filter('user_search_columns', 'q166419_user_search_columns' , 10, 3); function q166419_user_search_columns($search_columns, $search, $this){ ...


2

If you're looking to get in to instant notifications without suffering from backlog, I'd looking in to both Node.js and Socket.io. You should be able to work with them both pretty easily and integrate w/ WordPress. The sample chat application on the Socket.io site isn't a far cry from what you'd be doing. Basically an event is triggered on your LAMP/LNMP ...


2

Try this /* Save selected data */ add_action( 'personal_options_update', 'save_user_fields' ); add_action( 'edit_user_profile_update', 'save_user_fields' ); function save_user_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) return false; update_usermeta( $user_id, 'country', $_POST['country'] ); } add_action( ...


2

You could simply use the get_blogs_of_user() function: echo count( get_blogs_of_user( $user_ID ) ); instead of your custom SQL query.


2

The difference is that capabilities are part of the access permission system of the site, which utilize and can be changed by the built-in tools and APIs that are designed to handle permissions. You can create your own permission scheme but then it will not be easy to override with tools or code that expect access permissions to be handled in capabilities. ...


1

User Capabilities will allow you set site-wide access settings for a specific User/User Account Type whereas the meta-data allows you to make settings individually for each Post/Page or anything that supports Meta in Wordpress. In other words, Capabilities are part of ACL (Access Control Layer) whereas Meta is best when used for Data Presentation. User ...


1

This code works for me. It uses 'locations' custom taxonomy and 'suggest' javascript. You need to extend it to support multiple term selection. Add custom field to user-edit screen and store metadata when user/admin updates profile // for account owner add_action('show_user_profile', 'add_custom_user_profile_fields'); add_action('personal_options_update', ...


1

the_author_meta() is going to echo content directly. It will not pass a string back that can be processed by do_shortcode(). You want get_the_author_meta(), which is essentially the same as the_author_meta() but it returns a string instead of echoing the data.


1

After experimenting with birgire's comment (huge thanks), I put together a relatively simple regular expression that seems to be solid: SELECT * FROM wp_usermeta WHERE meta_key REGEXP('^wp_([[:digit]]+_)?capabilities$') The prefix can be easily added / changed without breaking the expression. It also requires at least 1 number and an underscore for any ...


1

Your query is wrong because your third argument to TIMESTAMPDIFF is incorrect. You should be using meta_value instead of SELECT meta_value. SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_wp_kc_last_active_time' AND TIMESTAMPDIFF( second, now(), TIMESTAMP(meta_value) ) > 5184000; Try that and see if the results start looking correct. I just ...


1

Well if you want to do this yourself first you'll have to make sure that the form supports enctype: /** Add Encryption Type to User Forms to allow Uploads **/ function profile_form_edit( ) { echo ' enctype="multipart/form-data"'; } add_action( 'user_edit_form_tag' , 'profile_form_edit' ); Then you're going to have to add a new field that allows users ...


1

As noted at the codex page for get_user_meta(): NOTE If the meta value does not exist and $single is true the function will return an empty string. If $single is false an empty array is returned. So I would suggest to do the check like this: ! empty( $themeta ) Regrading your other question, you can save the array by simply doing it like ...


1

If anyone should be faced with this problem, check if you have defined a callback function to set the user_login on pre_user_login. This filter is applied inside the wp_insert_user()-function and produced a same username again. Therefore the nicename was changed by adding a "-2". So, my problem was that I reset the user_logins again and again, instead of ...


1

It looks like you're using wrong parameters, please try this instead (untested): $q = new WP_User_Query( array( 'role' => 'contributor', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'first_meta', 'value' => '2', ), ...


1

As @Milo indicated. Be careful with sending too many emails or your IP will be banned/blacklisted. Personally I would prefer to create a table as email queue and send them with interval with WP Cron API. By default wp_mail() uses php mail() which is not much reliable and could end up in the Spam folder. Using SMTP for sending email is more reliable way ...


1

Turns out that the correct key was icl_admin_language. I was able to drop the key from the "get_user_meta" function and then print_r the variable. This showed me all custom user meta which I could then sift through for my desired key.


1

Take a look at PHP's array_values function. Alternatively, you could typecast. Note that if the array is in serialized form as you have put it above, you will have to unserialize it first, in either case. $numerical_array = array_values( unserialize( 'a:1:{s:8:"post-134";s:3:"134";s:8:"post-136";s:3:"136";}' ) ); or $numerical_array = ...


1

I think you will require to custom develop some part of it but most of it can be done with Contact Form 7 plugin. You can create forms with upload fields very easily in Contact Form 7. And you can make it visible for loggenin users only like this. <?php if ( is_user_logged_in() ) { echo do_shortcode('[contact-form-7 id="91" title="Form"]'); ...


1

These are not default fields added by Wordpress. They have to be added via a theme or plugin. You will need go and check where these fields are added. I would speculate that there are some kind of priority set when these fields are registered. You need to add a lower priority (higher number) to your filter function to make sure that your filter function ...


1

If I was in your shoes, I'd use get_user_meta(). // get the users -- I'm ordering them by their username $args = array( 'orderby' => 'login', 'order' => 'ASC', ); $users = get_users( $args ); foreach( $users as $user ) { $user_meta = get_user_meta( $user->ID ); var_dump( $user_meta ); // to show you what you've got } This is a ...


1

The problem is that when you pass the $key argument on get_user_meta() function, you don't pass a valid argument. The $key must be a string according to the documentation page. It represents the value of meta_key in the wp_usermeta table. If with wpcf-client-lvl is actually a variable that contains the name of the field ( lets say $wpcf-client-lvl = ...


1

Well, you comparing the results of the email_exists function with $current_user->ID. If email exists, email_exists() return the ID of the user using that email or false if the email doesn't exists. Imaging you are checking a email not being using, email_exists() return false and this if will validate: elseif(email_exists(esc_attr( $_POST['email'] ) ) != ...


1

Make sure to have identical keys in both of the arrays. Keys 'first_name', 'last_name' and respective keys 'fname', 'lname' are different. If you can make them identical then first do it, otherwise you will either need to do string manipulation for these keys before using them or put a condition like below in the foreach loop - foreach($user_meta_fields as ...



Only top voted, non community-wiki answers of a minimum length are eligible