6

Wordpress Ajax for connected user failed

 3 years ago
source link: https://www.codesd.com/item/wordpress-ajax-for-connected-user-failed.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Wordpress Ajax for connected user failed

advertisements

I am using wordpress 4.1.1. wp-admin and other several pages (like login, register...) use https connection. My goal is create ajax request for adding tickets to system.

So I can not call function for logged in user it calls function for not-logged in user. But when I add https for this page it`s work fine for me.

Question:

How I can keep user logged in on https and http, so is_user_logged_in() in amin-ajax.php works fine?


Just need to add one more line with your code :

for logged in users : 

add_action( 'wp_ajax_my_request', 'my_request' ); //calling function "my_request" for logged in users only

for non-logged in users : 

add_action( 'wp_ajax_nopriv_my_request', 'my_request' ); //calling function "my_request" for non-logged in users

for more information about addition of ajax in wordpress, just check here : http://www.wptricks24.com/how-to-use-ajax-wordpress/

Related Articles

wordpress checks for multiple user IDs

I am looking for a way to check if certian user id's are logged in.I didnt really want to create multiple roles for these users, hence why i am looking for a solution. this is what i have so far: <?php if ( is_user_logged_in() ) { $current_user = wp_

Disable Wordpress Limit for Duplicate User Email

I have a very big multisite. And I got a request to enable option that multiple users can use the same email. I found a plugin "Allow Multiple Accounts" which doesn't work properly. I should figure out some other solution for that. I know that I

Facebook Like Box is not displayed for disconnected users; only for connected users

I'm trying to add the Facebook Like Box social plugin in my website(I took the code from the official documentation). It works fine but only if I'm logged into Facebook; if not it just shows Facebook Public Profile Login to see this content I don't r

In MVC3, how do I use Session for Connected Users in my layout?

A fellow developer and I are porting a WebForms project over into MVC3, and we're new to this. We've got our WebForms master page ported to an MVC3 layout page, but the one thing that throws us is the Session for a logged in user. In the WebForms mas

Session Verification for Connected Users on Pages / Links?

When a user visits a page, does the system check if the user is loggedin on every page, with every link click or is this a one time thing? The issue I am having is: The user logsin which works fine. But if i enter the URL to my signup page the system

Design layouts for connected users & amp; Disconnected Resources

My App has two UI states: - Signed IN - Signed Out I've been using the following to determine which app/view/layout to use based on if the user is signed in or out with Devise: # Devise, way of using a different Layout for all the devise/non-signed i

Large-scale commerce only displays certain products for connected users

I am developing an e-commerce application using broad-leaf commerce. My requirement is I have to add an product from login panel and display that product to only logged in users. Here few product products will be visible to all users (guest too) and

Singleton model for connected user

I handle user login/registration without ember for now, but I'd like to handle user profile within ember (edit the profile). What would be the best course of action to have a singleton model that would handle current user? I defined a simple user as:

How to protect a page only for connected users?

I created a login form that works great. But I realized the page my user is directed to can still be accessed by anybody. How do I protect the page being accessed only viewable by those logged in? Do I need to place a script on the success page itsel

Calling HTTPS from HTTP via AJAX for connection

I know its violates the Same origin policy, and that is why it is not possible through simple ajax request. I could use JSONP. But using JSONP for login doesn't sound secure ( no post only get ). So is there a more secure way of implementing login in

How to restrict a directory only for connected users only: Codeigner

I have a directory in my project on the root, out side the application folder as follows. localhost/my_project/my_directory so how i can protect my_directory that only logged in users can access this and if anyone not logged in and direct access this

Specify a different path for connected users without using Currency

If the user is logged in, I want users#show to be the route path. Else, the route path should be static_pages#home. Please let me know how I can achieve this without using the Devise gem.I think having if/else statements in your routes file isn't rig

ASP.Net: Display of buttons only for connected users

I want to show a few buttons to users who are logged in. I don't use Membership Provider but Session. Can I still somehow use LoggedInTemplateor should I do it some other way? I store the session user like this in OnLogin button event: SqlCommand que

ActiveRecord Rails: Default Range for Connected User

I have a Post model that is associated to users (think of 'post owner'). class Post < ActiveRecord belongs_to :user (...) end In my Post#index action/view, I want to only display posts that belong to the currently logged-in user. So first approach wo

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK