Tag Info

New answers tagged

2

The solution that we have gone with in the end uses a single call to get_user_meta passing just the $user_id - this way all user data is returned in a single query, reducing a heavy load on the DB during large user data exports. We then run a series of checks against the returned data - including: is_serialized( $value ) - to check if the data has been ...


3

You can add this to your functions.php file in your template to allow the user to edit pages that they have created. Just specify their $user_id (i.e. 27): //to add capability to $user_id $user = new WP_User( $user_id ); $user->add_cap( 'edit_pages' ); $user->add_cap( 'edit_published_pages' ); You can find a specific user's $user_id from the URL ...


2

Not being able to find anything I finally went ahead and created the WordPress plugin Terms before download. From the plugin's description: Terms Before Download adds a shortcode that can be used instead of HTML anchors to link to downloadable files. If such a link is clicked a popup dialog shows terms and conditions (EULA) which must be accepted ...


0

I've found these errors in your code: The saving proccess of custom user fields is hooked to registration but not to update user profile actions. You are using update_usermeta, a obsolete function, use update_user_meta instead. You are using get_the_author_meta with $user->ID without checking before if $user is an object, which generate errors on new ...


2

You need to use the login_redirect filter returning the redirect location: add_filter( 'login_redirect', 'redirect_to_home', 10, 3 ); function redirect_to_home( $redirect_to, $request, $user ) { if( $user->ID == 6 ) { //If user ID is 6, redirect to home return get_home_url(); } else { //If user ID is not 6, leave ...


1

use login_redirect hook instead login_form And you can move conditions inside your function like below code. function redirect_to_front_page() { global $redirect_to; if ( is_user_logged_in() ) { $user_id = get_current_user_id(); if ($user_id == 6) { /* redirect users to front page after login */ if ...


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.


0

I just wanted to say thank you for this article because I've been searching for a solution to this problem for a long time. It was simply because I had used a plugin to clone my sites and it never updated the wp_##_user_roles properly. When the site copied over from wp_13... it was cloned over to a new site wp_81... but this entry was still stuck at wp_13.


0

For starters recovering your own access would be good. If email approach fails for you, Codex has Resetting Your Password page which gives instructions for several more approaches. To troubleshoot the issue in general you should start with disabling plugins / using default theme, and likely checking WordPress core files for modification or simply replacing ...


0

Try this code: (edited code a little) add_action( 'template_redirect', 'my_page_template_redirect' ); function my_page_template_redirect() { global $post; if( is_user_logged_in() ) { if( is_single() ){ if( $post->post_author != get_current_user_id() ){ wp_redirect( 'IN ANY PAGE' ); } } ...


1

You need to select either of option button: "Delete all content" or "Attribute all content to:" then "Confirm Deletion" button will get enabled. If you are not able to see the button itself then some plugin css must be hiding it. So please try deactivating plugins one by one and check if you can see the button.


0

It is enabled by default. Check that WordPress is sending emails at all, you might have problem with the SMTP settings. Where is your website hosted? Did you check the spam?...


0

current_user_can( 'edit_user', $user_id ) This term performs a check on the »meta capability« edit_user. By default, it maps to the capability edit_users, which is a typical capability for the admin role. Furthermore it compares the ID of the current user and the user ID given as parameter. If they match, the statement becomes TRUE, because each user ...


0

All it's doing is checking the current user's capabilities against the user-in-question, and returning a boolean value. I don't think 'good practice' can be applied to this scenario without a more complete picture of what you are trying to do. (what code will be executed if the bool is true?) That being said, I see no problem with simply using this check, ...


1

Yes it can be good practice to check if a user is capable of doing something before doing something related in code. For example, don't save a custom post type if the user doesn't have the capabilities needed to do it, or don't show certain things to users who don't have the manage_options capability ( super admins and admins normally ). Bad practice in ...



Top 50 recent answers are included