New answers tagged

0

it was just missing $upload_dir['path'] . "/" . $upload_file_name in $uploaded_file['attach_id'] = wp_insert_attachment($attachment, $upload_dir['path'] . "/" . $upload_file_name); require_once(ABSPATH . 'wp-admin/includes/image.php'); //Generate the metadata for the attachment, and update the database record. ...


-2

We have a company that allows banks to register within their site with a membership.... If you're dealing with banking info (and not even financial data), employee data, course registration, tickets, etc., you're absolutely foolish to pull a random php function from the web and try to integrate it into a WordPress theme and expect the results to work ...


1

You can use pre_get_users since WP 4.0.0 function my_user_sort( $query_args ){ if( is_admin() && !isset($_GET['orderby']) ) { $query_args->query_vars['orderby'] = 'ID'; } return $query_args; } add_action( 'pre_get_users', 'my_user_sort' );


0

Adding to what Mark Kaplun said, you could probably have a look at User Meta Sessions Tokens. They can tell you, if there is an active session for a specific user. But that does not mean, that the user is active on the site and doing something, just that he logged in successfully. Anyway, don´t trust anyone that tells you to use is_user_logged_in()! That´s ...


0

On init set a transient for, say, 5 min that keeps updating as long as the current user (in this case, any admin) is poking around. Dump a list of those active transients from a shortcode into a page. That should do it.


2

Wordpress do not have a true concept of "logged in". Although the labels all around use the term, in the code the closest you get is something that might be called "authenticated users". The difference is that the authenticated user might be one that has his browser closed and therefor he is not "logged in". To do what you want you will first need to define ...


-1

UltimateMember pages are based on [shortcodes] which will be entered into normal Wordpress pages. By this means the user-profile page, which you are referring to, should be listed under your WordPress pages, the default name generated by Ultimate-Member is "User page". Search this page and edit it, you will see some content like this [ultimatemember ...


-1

This works for me. I am using WP-Members plugin (and hook). add_action( 'wpmem_post_register_data', 'my_registration_hook', 1 ); function my_registration_hook( $fields ) { wp_set_current_user( $fields['ID'] ); $creds = array( 'user_login' => $fields['username'], 'user_password' => $fields['password'], 'rememember' ...


2

After writing those two lines in wp-config.php, your users data will be shared between both installations, but both installations will also need to have the same cookie parameters, so in wp-config.php file of your second installation, modify the COOKIE_DOMAIN like this: define('COOKIE_DOMAIN', '.{yoursite.com}'); //replace with URL of first site ...


0

if(current_user_can( $capability )){ html to display appropriate page } else { header('Location: http://www.registrationorloginpage.com/');} Check the capability of the user and redirect if insufficient privileges.


-2

Yes you need to customize that OR use sortcode. The only time I'd recommend filtering by attribute is when looping events in PHP and checking the $EM_Event->attributes array before displaying the event. if you want a field like 'assigned to', I'd recommend adding a custom attribute as per tutorial. also, instead of do_shortcode, use something like: ...


0

You want to disable the option to delete, If you mean the delete button on the user list at /wp-admin/users.php you can use user_row_actions class to hide the 'delete' link with below snippet: add_filter( 'user_row_actions', function($actions, $user_object) { $result = new WP_Query( array( 'author'=> ...


0

Your code does not work because in foreach loop get_userdata($bloguser->user_id); line, $bloguser is an unknown object variable. Please try this code: $get_admins = array( 'role' => 'admin', 'orderby' => 'user_nicename', 'order' => 'ASC' ); $blogusers = get_users( $get_admins ); echo '<ul>'; foreach ( $blogusers as $user ...


-1

WordPress defines a class called wpdb, which contains a set of functions used to interact with a database. First to initialize a global object variable, $wpdb, which is an instantiation of the wpdb class defined in /wp-includes/wp-db.php. <?php require_once( '../../../wp-config.php' ); global $wpdb; if ( is_user_logged_in() ) { ...


-1

Here is my answer in code form: <?php // Customer Details $args = array( 'blog_id' => $GLOBALS['blog_id'], 'role' => 'customer', 'meta_key' => 'last_name', 'meta_value' => '', 'meta_compare' => '', 'meta_query' => array(), 'date_query' => array(), 'include' => array(), 'exclude' => ...


1

Prior to Wordpress 4.5 get_currentuserinfo() was an acceptable option, but is now deprecated, in favor of wp_get_current_user(). You can set the wp_get_current_user() as a variable to easily access it in your function or page: $current_user = wp_get_current_user(); Example: if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); ...


1

This is how you can get current user: global $current_user; $current_user = wp_get_current_user(); After that, you can use $current_user->ID where you want. Example: if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); echo 'Username: ' . $current_user->user_login . '--'; echo 'User email: ' . ...


0

When you click on "delete", the action 'delete_user' will be launched: https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-admin/includes/user.php#L313 After that you can check, if the user has written at least one 'portfolio' post. add_action('delete_user', 'sw_portfolio_check'); function sw_portfolio_check( $user_id ) { $result = new ...


0

Here is how you can find the list of roles without any plugins or function http://screencast.com/t/uaWsGLAR3Sh


1

A quick (and dirty) solution would be to prevent the final deletion where it happens (function delete_user). You could implement a little plugin or paste the code into your functions.php: <?php /* Plugin Name: Please don't delete me! Description: Prevent accidental user deletion of my account */ define('PDDM_USER_ID', 1); // User ID of your Account ...


1

Here is another approach in which we can answer the question, here is a small Plugin that adds a Submenupage for "Users", containing a small form where you can enter a username to create the new user with no emailadress. Additional Error handling allows you to see if the current user already exists, as usernames have to be unique. Create a ...


0

There is a function that lets you enter users without any email address at all! If that's what your looking for? Just put this piece of code in your functions.php // Remove required email address in user profile function remove_empty_email_error( $arg ) { if ( !empty( $arg->errors['empty_email'] ) ) unset( $arg->errors['empty_email'] ...


0

That is not possible in an easy way, as WordPress always checks if the Emailadress is already used. function email_exists( $email ) { if ( $user = get_user_by( 'email', $email) ) { return $user->ID; } return false; } This function is also not filterable, so there is no way around in this direction. What you could do, however, is ...


0

Use the function current_user_can( $capability ). Where $capabilty applies. For example: If ( current_user_can( 'update_plugins' ){ //do some update plugin stuff }


2

I would recommend the following: The Editor user role in WordPress cannot by default edit users. You may want to add that capability for clients whom you keep as 'Editors'. This will let the Editor add new users (create new users), delete users, and edit users. This is done by adding capabilities to the Editor role with 'add_cap'. This lets Editors ...


0

You can do it... You need to add the image to your media. Copy that media file URL and paste/link it to your custom user avatar url under edit user. SORTED!


0

Best way i think would be to add an array of read post IDs to the user meta table and use them in the 'post__not_in' Parameter in the pre_get_posts hook. In my mobile right now, so i will edit this answer once i'm at work to insert a code example.


0

You need to use the show_user_profile, edit_user_profile, personal_options_update, and edit_user_profile_update hooks. You can use the following code for adding additional fields in User section Code for adding extra fields in Edit User Section: add_action( 'show_user_profile', 'extra_user_profile_fields' ); add_action( 'edit_user_profile', ...


2

This would be best as a comment, but no reputation :) In the codex they say "If you are defining a custom role, and adding capabilities to the role using add_role(), be aware that modifying the capabilities array and re-executing add_role() will not necessarily update the role with the new capabilities list. The add_role() function short-circuits if the ...


1

You can override the default query arguments using users_list_table_query_args: function wpse_214577_users_list_table_query_args( $args ) { if ( empty( $args['orderby'] ) ) $args['orderby'] = 'ID'; if ( empty( $args['order'] ) ) $args['order'] = 'ASC'; return $args; } add_filter( 'users_list_table_query_args', ...


0

I am not sure why you have written codes this way to add user role. And wp_usermeta table does not contain capabilities. It holds only roles assigned to that specific user. Capabilities are stored into wp_options table. To add role into Wordpress, just use add_role() function. Here is the documentation. If you want to remove/change any user's role, you can ...



Top 50 recent answers are included