Tag Info

New answers tagged

1

You are trying to access the meta data of the user with ID stored in $user->ID but the object $user is not defined in your code. You are also using an undefined variable $user_ID. The quickest fix in your code would be to change this: get_the_author_meta( 'province', $user->ID ) ) With: get_the_author_meta( 'province', $userdata->ID ) ) Tip: ...


5

The user passwords are stored in one-way encription. Even looking at the database you can not know the password. The is a very basic privacy feature. Most users use the same password on multiple sites; imaging the potential risks for users if the administrator of the site can access to their passwords. You can intercept the password from the ...


0

You can write a small custom plugin, that run on the activation hook. A example, write from scratch function fb_add_roles( $user_id ) { foreach( get_blog_list( 0, 'all' ) as $key => $blog ) { if ( is_user_member_of_blog( $user_id, $blog[ 'blog_id' ] ) ) continue; switch_to_blog( $blog[ 'blog_id' ] ); $role = ...


0

I used the below code in the end. Hope someone finds this useful. /* Display only user-uploaded files to each user in Media Library for file upload form*/ function user_restrict_media_library( $wp_query_obj ) { global $current_user, $pagenow; if( !is_a( $current_user, 'WP_User') ) return; if( 'admin-ajax.php' != $pagenow || ...


0

As mentioned by the others: If you call the function too early it will return value 0 A good way to check if it's "too early" or not is this kind of checking: // Do NOT check for action 'set_current_user', but for 'init'!! if ( ! did_action( 'init' ) ) { _doing_it_wrong( __FUNCTION__, 'get_current_user_id() called before the init hook', null ); } ...


0

The best way is to define a new role. An easy way to accomplish this is with the role scoper plugin. Otherwise you'll just have to write that plugin yourself manually. Here is a basic example pulled from the Codex $result = add_role( 'basic_contributor', __( 'Basic Contributor' ), array( 'read' => true, // true allows this ...


1

You are using pre_user_query according to WordPress documentation Fires after the WP_User_Query has been parsed, and before the query is executed Then you should use pre_get_users just like pre_get_posts when your arguments have some meaning to WordPress. pre_get_users Fires before the WP_User_Query has been parsed Replace your hook with ...


1

Generally speaking I agree with most of the other answers but, if for some reason you really had to merge two accounts here is how that could work. Merging User-B into User-A Reassign all of User-B's content to User-A Determine the highest privilege of User-B If higher than the privileges of User-A elevate User-A's privileges else do nothing. If you have ...


0

What's easy to do is transferring posts of a user to another user. I think you can just simply delete it and transfer everything to an existing user. But user roles… I'm not sure why you'll have to transfer that to another user. Can't you just simple create another user with the same permiossions and merge the posts of both?


0

No, you cannot merge two users. What you can actually do is add the new user then transfer all the posts to him. When you add the new user you can define his rule. In your case the new user should be an 'Admin'. Thus he will have access to all the contents as well as rights for everything. Moreover this simple process is also very easy to perform


0

You might simply want to go to Settings > General. Here you can select the standard role a user gets, once he registers.


1

Use wp-admin/admin.php with an action parameter: <a href="<?php echo esc_url( admin_url( "admin.php?action=wpse_184153_create_page&user_id=$user_id" ) ) ?>">Create Page</a> And then hook onto the event: function wpse_184153_create_page() { $redirect = admin_url( 'users.php' ); if ( ! empty( $_GET['user_id'] ) && ...


0

What about putting the city/regions/whatever into an array you can loop through? Something like this: $cities = array( 'Richmond', 'Chicago', 'New York' ); foreach ( $cities as $city ) { ?> <h2><?php echo $city; ?></h2> <ul><?php foreach ( get_users_by_meta_data( 'school_division', $city ) as $user ) { ?> ...


-1

This is some sample code needed for making an individual color scheme. wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array( '#07273E', '#14568A', '#D54E21', '#2683AE' ) ); Source file: wp-includes/general-template.php /** * Register color schemes. */ function add_colors() Example: Scroll down to find the ...


0

It just depends on how many sites you want to update. I don't have a lot of sites to manage so I went with individual installs. Most of the updates are automatic these days so everything is easy. I can also test where bugs are easily having different sites. You might need a lot of space though, doing what I do.


0

As stated your use case seems suitable: multiple sites — check shared users — check WP multisite does this. However there aren't that many details in your question beyond that. It is a guesswork to recommend for or against it for such a complicated site, without knowing requirements thoroughly.


0

I have found a great tutorial here that have helped me to developing a custom user search. This is my solution: <?php /* Plugin Name: Simple User Listing Description: Create a simple shortcode to list our WordPress users. Author: Damiano Fossa Version: 1.6.3 */ function sul_user_listing($atts, $content = null) { global $post; global $wpdb; ...


2

I am not sure exactly what you are asking for, but, if you want to target a specific user ID, just do something like: // set special user id $special_user_id = 5; $current_user_id = get_current_user_id(); if ( $special_user_id == $current_user_id ){ echo 'special user is online'; } You get the idea.


0

The easiest trick is to use the user_contactmethods - the fields don't actually have to be contacts, but WordPress will do all the leg work for you (displaying the fields & saving the data): function wpse_183763_user_contactmethods( $methods, $user ) { $methods['my_field_1'] = 'My Label For Field 1'; $methods['my_field_2'] = 'My Label For Field ...


0

Add Custom Class In Custom Column custom posttype / post/page/ and user list Table . This is a Simple Please Try This Add column name like "purchased-leads num " space between for separate class. Add Add "num" Class in Column And Auto Text align Center like Post count , no need Any Other css . add_filter( 'manage_users_columns', ...


0

Use get_category() to convert the ID into a category data object. $cid = get_user_meta($uid, 'user_location', true); $c = get_category($cid); echo $c->name;


-1

Got it fixed. Pretty simple actually. I moved the if part where the user get's deleted to the bottom of the script. foreach ($data as $gebruiker){ $username = $gebruiker['username']; if ( username_exists( $username ) && $gebruiker['status'] == 'published' ){ $user = get_user_by( 'login', $username); update_user_meta( ...


1

This is not possible, since the output of your gtp_users_table_content function for the manage_users_custom_column action hook is printed within predefined <td></td> elements. However, you can put a simple div with a class around your output: // Add users table lead purchase column content add_action( 'manage_users_custom_column', ...


1

You can use wp_create_user and pass necessary information like $username, $password, $email , where $email is optional. If user created successfully it will return ID of newly created user, other wise will return error object. Then update user's other information using update_user_meta.


0

You can make use of CSV importer/exporter libraries to extract the CSV file data and save them as user details. FYI - always use wordpress functions to save anything. for ex. update_user_meta etc. Cron you are using is correct and should run properly. Library for extracting CSV data : goodby EDIT: try adding a error handling in your code: //On success ...


1

You could take a look at the contributors function included in Twenty Fourteen if ( ! function_exists( 'twentyfourteen_list_authors' ) ) : /** * Print a list of all site contributors who published at least one post. * * @since Twenty Fourteen 1.0 */ function twentyfourteen_list_authors() { $contributor_ids = get_users( array( 'fields' => ...


-1

Just needed to use get_author_posts_url($user->ID)



Top 50 recent answers are included