Tag Info

Hot answers tagged

4

First of all, you ned a function (template tag) to display the url. You can write a custom function that output the url in the format you want, however, putting the username in a public url can be a security issue. The function can handle the link and accept an argument $user that can be a user id or a user object. If non is passed, the function will try to ...


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 ...


3

wp_insert_user returns your new user's ID, if created successful. You can add the user_meta to this ID: $userid = wp_insert_user( $userdata ); if ( !is_wp_error( $userid ) ) { // check if insert was successful add_user_meta( $userid, 'verification_ref', $ref ); // add the meta } else { /* Error Handling */ }


3

I came across a tutorial about 'Custom User Taxonomies in WordPress' and there is a plugin based on that 'User Taxonomies' but these are for creating taxonomies for Users. Have a read thought the tutorial it might help. I think what you're talking about is to associating posts' taxonomies with users. I think you need to use something like ...


2

How can I write a bulk MySQL command to add in the value wp_capabilites='a:1:{s:10:"subscriber";b:1;}' into each user_id except 1, 2 and 3 ie. the newly imported users? You don't. That is a serialized array which is a PHP construct. MySQL has no idea what to do with it. To the database, it is just an string. To PHP it is a representation-- a ...


2

You made a lot of statements here, so let's go through them bit by bit. while keeping database queries low The amount of queries isn't directly an issue, time that they take is. Single really slow query can take more time than hundreds of very fast ones. before the website loads (or the first time a website loads) Since WP is PHP application ...


2

Do you have any data showing that user meta won't work? Until you do — don't mess with it. You are not likely to get from-scratch solutions as convenient and more performant without significant effort.


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

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.


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

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

You don't need a checkbox, you can code one if you want, but you can use the default Custom Fields. Make sure they are enabled: Then add some data on the posts you want to have a specific style on, you will need to add this to each post you want to have set to display: none;: Now inside the loop of your page you will add that value as a CSS class: ...


1

The following code will display "Biographical Info" in "Add User" form function display_bio_field() { echo "The field html"; } add_action('user_new_form', 'display_bio_field');



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