Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
80 views

Add custom css to specific user

I need help with something for my wordpress site. I want to add custom css to a specific user. For example, user B. but I couldn't do it. Here I tried the following css code: div [user="id"] ...
ByWorld's user avatar
0 votes
1 answer
30 views

Whats the proper way to add a new user via a front end form?

I am building a form on the front end that allows the user to add a new user by filling out the name, email, and password fields and hitting submit. I understand that I can use wp_insert_user() with ...
patricko's user avatar
  • 101
0 votes
0 answers
116 views

Change wordpress' database data using ajax - how to get current user id?

I want to update a wordpress' database using ajax. I've created php file and included both wp-includes/user.php' wp-includes/pluggable.php' and when I call $current_user = wp_get_current_user(); $...
exemce's user avatar
  • 1
0 votes
2 answers
2k views

Allow a user or role to view drafts and previews, but not other admin privileges?

How do I allow a specific user or a specific role to view drafts and previews, but not allow them to edit posts or have any other admin capabilities? I can add a custom capability to a role, but don't ...
Michael's user avatar
  • 281
0 votes
1 answer
998 views

How to Use Global Variables Inside Header and Footer

I set global variables for some custom user data in my functions.php to use them in navigation inside header and footer. if (is_user_logged_in()) { # users wordpress id global $user_id_wp; ...
Robin Alexander's user avatar
0 votes
1 answer
1k views

Get current user id in function php

I know that this question is already often asked but there is no exact answer for it. I need to get the loggedin user id to change a value in the database for this user. I tried 2 ways it didn't work. ...
Nabil Dabbagh's user avatar
1 vote
0 answers
102 views

How to make custom column Admin>Users sortable?

I have a few hundred users (customers) to delete, specifically those that registered before 2019 and have zero orders. I've added the following code to my child theme functions file in order to add a ...
Cleopatra's user avatar
4 votes
3 answers
3k views

Add new user : make the fields First Name and Last name required

I'm searching how to make First Name and Last name fields required when we add a new user. Right now only username and Email fields are required. I found a way by adding class="form-required"...
Samuel's user avatar
  • 354
0 votes
0 answers
39 views

Deleting guests profile users after 1.5 hours

I need to automatically delete the users that are subscribed through a wpforms after 90 minutes of being created. Users created this way are marked as "invitados" on the profile. I found ...
Victor Vazquez's user avatar
0 votes
1 answer
369 views

wp_get_current_user return ID = 0 when used outside of wordpress, such as webhook / fulfillment dialogflow

I want to get the user ID that is currently logged in. I did it successfully when accessed via a web browser. However, when this function is called via dialogflow as webhook / fulfillment it always ...
Royhan Au's user avatar
0 votes
2 answers
473 views

Condition OR for current user ID

I'm tryng without success to create a custom backend based on user ID, if user id is different the 1 or different then 2 show custom backend. This is my code but it doesn't work, any help would be ...
user1818326's user avatar
0 votes
1 answer
513 views

Secondary Menu and Logged In Users

I'm using the below code to display two different menus in my storefront based child theme based on a users logged in status. But When I have a secondary menu (links by the search bar) it is replaced ...
T. Thomas's user avatar
1 vote
0 answers
507 views

Execute a ultimate member action when user role is updated

I want an Ultimate Member action to be performed when I assign a particular role to a user. A role "old_member" exists. If I assign this role to a user, the account should deactivate itself with the ...
anilgky's user avatar
  • 11
1 vote
0 answers
14 views

Filter out other users comments. Visualize only own comments and editor role users' comments

I have a similar request as per question but I am totally not into php and would not know where to start to make such edits based on the answer provided. Would be great if anyone could help here. ...
Carlo's user avatar
  • 11
1 vote
1 answer
515 views

Allow user only create specific tags

I am using an editorial wordpress theme that has a frontend post editor for a user (contributor) to create a post. The editor is giving permission to the user to choose category for the article and to ...
Honoluluman's user avatar
0 votes
0 answers
99 views

Add Change role button for list of user in an event

I need a custom code function which upgrade user role in bulky action just like the default Wordpress change role function in all user Wordpress section
Stephen Wolfram's user avatar
0 votes
0 answers
104 views

get_current_user_id() always return 0 in if else statement

I'm trying to get logged in user id after if else statement but always return 0. When i put get_current_user_id() before it gives correct user id. How can I make it work in if statement? <?php ...
MrLentis's user avatar
0 votes
1 answer
1k views

Why get_user_by() doesn't work in my code?

I am editing the code of a plugin to add a small functionality that I need. I almost made it work, but I really struggle and don't understand why $user_id_for_um_groups = get_user_by( 'email', $...
anastasia_pz's user avatar
0 votes
1 answer
4k views

Display current user metadata on Wordpress page

So I have a Wordpress website, and I want to be able to display the current logged in user's data on a page. Previously, I had been able to find a snippet of code that would go go in functions.php and ...
FAQ Tutoring's user avatar
2 votes
1 answer
38 views

How can I default to all WordPress roles when parameter is not included in shortcode?

I am trying to set up a generic shortcode in WordPress with parameters for user meta key, meta value and roles that will count the total number of profiles that include certain values. So far I have ...
Michael's user avatar
  • 281
1 vote
1 answer
2k views

Call to undefined function get_userdata() in plugin

After refactoring/restructuring files in my plug-in, I now get the error Uncaught Error: Call to undefined function get_userdata() after code $current_user_id = get_current_user_id(); $...
TTT's user avatar
  • 329
0 votes
1 answer
577 views

Filter to wp_list_authors

I am using wp_list_authors, to, how function name says, make a list of authors, but i want to show only "Authors". Now in my site, any account who publish a text ("Admin", "Editor") show his name in ...
Matheus Ribeiro's user avatar
0 votes
1 answer
755 views

Cross origin ajax request always returns 0 when calling get_current_user_id();

I currently work on localhost and when I want to test ajax requests to my web server, the function get_current_user_id() always returns 0. When I make the ajax request from my website however, it ...
Tim von Känel's user avatar
0 votes
0 answers
347 views

Add another role to a user when they click a button?

On my site, there are roles "user, authors, etc.". Default role for user is "User" which I want to keep it for all users. How to add another role to a user when they click a button? I tried with my ...
Alief's user avatar
  • 15
3 votes
2 answers
2k views

wp_delete_user with username

wp_delete_user() function requires user ID and [optional] reassign ID if the content is to be reassigned to another user. All users' user names are also unique as WP doesn't allow duplicate user ...
Rajesh Kakkad's user avatar
0 votes
0 answers
55 views

Update User Meta Via Ajax

Can someone please tell me what I'm doing wrong here? I have an ajax function which runs every few seconds and it basically checks 2 database tables and if they do not match then update one of the ...
Matt H's user avatar
  • 111
0 votes
0 answers
1k views

is_user_logged_in() not working in homepage

I am building a website using the Eduma theme and I am using is_user_logged_in() inside the logic of my login / register widgets but it does not seem to work in the homepage of my site. After logging ...
alberto montalesi's user avatar
3 votes
1 answer
1k views

Can i check if user is doing any ajax request?

I make a custom user meta and its name is last_activity. I use this meta to get the date of user last activity and I updated the meta each time user open a page using WordPress wp_head action. My ...
Mido's user avatar
  • 77
2 votes
1 answer
209 views

password protected post policy

I'm looking for a way to add policy about POST password. Password specifications : 12 characters in length, 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character. Is ...
Samuel's user avatar
  • 354
2 votes
1 answer
2k views

Force to use STRONG users password and implement rule to prevent REUSE [closed]

I'm looking for a way to force using strong password when we create reset and change users password on WordPress backoffice. Password complexity must be at least 12 characters in length, and have at ...
Samuel's user avatar
  • 354
4 votes
2 answers
10k views

Create a global variable for use in all templates

I used following code function userinfo_global() { global $users_info; wp_get_current_user(); } add_action( 'init', 'userinfo_global' ); in a file users.php , this file are call in inside ...
Juan David's user avatar
1 vote
1 answer
213 views

Get users that likes the post

I have an ajax like posts system when a user like a post the system added a post meta to the post and it's named (post_liked_users). Example of post_likes_users meta value: a:1:{s:6:"user-1";i:1;} ...
Trello's user avatar
  • 111
1 vote
1 answer
973 views

create shortcode to list users with specific meta key value

I have a function that I use to list users within a specific role, that match a specific meta key value. It works when I use it directly on the page --- <?php $bmail = $current_user->...
730wavy's user avatar
  • 193
0 votes
1 answer
147 views

Show users last read posts for each user?

I'm trying to get logged in users most recently read 10 posts to show on their profile. For example: user A's most recently read 10 posts user B's most recently read 10 posts... I tried creating ...
Al safraz's user avatar
-2 votes
1 answer
216 views

how to get and display logged in user's recently read posts

I want to know how to display logged in user's most read posts and display them? I have a blog system with user login and need to display their most recently READ posts on their profile
Volka Dimitrev's user avatar
0 votes
1 answer
103 views

Can't get_users info by using json_encode

Here's the code that i used: function get_users(){ $all_users = get_users(); $arr=array(); foreach ($all_users as $val) { $arr[]=$val->data->user_nicename; } $resp = ...
Trello's user avatar
  • 111
0 votes
1 answer
447 views

How to add array [closed]

I have this following code, if ('plugins.php' === $pagenow ||'update-core.php' === $pagenow ) { // wp_safe_redirect( home_url() ); // Now check the current user $user = wp_get_current_user(); ...
Pravin Nath's user avatar
1 vote
0 answers
429 views

Change label for registration Fields

I want to change Label of Username and website on add user page and profile page. I also looking for a way to change username label on list users and hide mail column I'm looking for a way by adding ...
Samuel's user avatar
  • 354
0 votes
1 answer
2k views

Add Link to Users List (Backend) to open each users front-end profile

As default the Users Screen in the Backend allows me to add, change, or delete my site's users: Now i need a additional url in the user list, wich redirects me to each users front-end profile (e.g. ...
Learning by doing's user avatar
0 votes
0 answers
27 views

Matching multi user

I wanna matching two strings' user ID and show only matching user id... $followers = get_user_meta($user_info->ID, '_Followers User ID'); $following = get_user_meta($user_ID, '_Following User ID');...
user3568652's user avatar
1 vote
2 answers
6k views

Get Current User info using wp_localize_script, in functions.php

I need to pass the info from wp_get_current_user() to the front end for a script that uses it. To achieve this, I am using wp_localize_script() to pass the information. I put the code at the top of my ...
CaesarOG's user avatar
0 votes
0 answers
65 views

Private messaging - Getting and displaying the avatar/url of a message recipient

Is there a simple function/script to get the avatar/url of a message recipient? For instance, let's say user A sends a private message to user B. In user A's message list, it now displays user A's ...
kosmicbird's user avatar
6 votes
1 answer
6k views

Get a list of all available fields in the User Profile

By default, the User Profile page has a few options and fields that the user can set. Such as the following: Personal Options -- Visual Editor -- Admin Color Scheme -- Keyboard Shortcuts -- Toolbar ...
Ethan Rævan's user avatar
  • 4,029
0 votes
1 answer
77 views

How to add number to wordpress count function?

I am using a function on wordpress that accurately counts registered users. How could I edit this function code to add a number to the counter? For example, so it outputs registered users + 100. ...
user91325's user avatar
0 votes
2 answers
1k views

Every time I use wp_get_current_user() my plugin breaks

I have been trying to make a sign-out plugin that allows users to sign out from military training activities that they should be at. After they fill out a form explaining why they are not going to be ...
FriedRyan's user avatar
0 votes
1 answer
66 views

Suggest Users basing on User taxonomy

My question is for getting informations or directions about how to move for a task I have to do. This is just a request for advices due to the fact I'm not an expert in wordpress development. My task ...
Kleeia's user avatar
  • 107
8 votes
2 answers
1k views

Use author author display name in permalink structure for pages and posts

I need to add the author name as a subdirectory prefix for all user's posts and pages. For example: example.com/johndoe/ //The author page for John Doe example.com/johndoe/category/test-post/ //Test ...
bigmike7801's user avatar
1 vote
2 answers
73 views

Don't delete a page if it holds users

I have to do something but I just can't come up with a way to do it. On one hand I have created pages who are companies. So every page is a company-page. On the other hand I have created users who ...
Interactive's user avatar
  • 1,006
6 votes
1 answer
916 views

Keep one user logged for a year?

This has got to be simple: how do I keep one user - my-user - logged in for a year? (I'm checking logged in cookies in the dev tools console). Update 8/16/15 This works: add_filter( '...
markratledge's user avatar
  • 8,735
0 votes
1 answer
3k views

Showing user profile data on front-end

I'm making a profile-page so my members can update they're details trough the front-end. The problem is that the select-box named "Province" won't show the correct data when the page loads. How can i ...
Demilio's user avatar
  • 883