sergio79
Forum Replies Created
-
Forum: Plugins
In reply to: [User Switching] Strange cookie behaviourHi John,
actually in a custom function of mine I had tried to extend the cookie expiration:
add_filter(‘auth_cookie_expiration’, ‘extend_cookie_expiration’, 10, 3);
function extend_cookie_expiration($length, $user_id, $remember) {
return 60 * 60 * 168;
}Commented out this function, now everything seems to work correctly. Does this make sense?
Hi Mia, did you carry out that test with the Lite or Pro version?
I’m on the free version right now (I’ll be purchasing it soon), so I can’t open tickets on ninjateam … I just wanted to report this glitch (waiting for a bug fix).
Sure!
Forum: Plugins
In reply to: [User Switching] Use for woocommerce user switching and order entryHi John, I wanted to know one last thing:
when I switch from admin (or other role) to a user, I am redirected to the /account page (but I can also change it by adding the redirect_to query argument) and the URL is “clean”.
However, when I click on the link to return to the starting user, the URL is enriched with “user_switched=true&switched_back=true”. Are these parameters necessary? Can I somehow remove them?
Thanks so much!
Forum: Plugins
In reply to: [User Switching] Use for woocommerce user switching and order entryI’d like to update you, I think I’ve solved it:
in my process, I call an AJAX action that I call with a dropdown populated with a list of users.
With the function explained here https://www.ads-software.com/plugins/user-switching/#can%20i%20add%20a%20custom%20%22switch%20to%22%20link%20to%20my%20own%20plugin%20or%20theme%3F unfortunately the URL contained the & encoded, so I had to add an “htmlspecialchars_decode” to the generated $url, and now everything works! <3
Forum: Plugins
In reply to: [User Switching] Use for woocommerce user switching and order entryI think (maybe) I understand the problem.
I tried to simulate user switching on the frontend side, this time as an administrator, and not as a custom role (to be enabled for the user switching function).
When I am in the user list (backend), the “Switch to” button has an address like this:
wp-login.php?action=switch_to_user&user_id=1234&nr=1&_wpnonce=d6d1234aa1
… clicking it works , I am redirected to that user’s dashboard. If I open the frontend obviously I find myself on the website logged in as that user. Everything works.
In my case I was trying to insert a user list (a filtered drop down menu with a list of “customer” type users) on the frontend, and when selected a user I wanted to activate your function, but always send him back to the home of the site.
When I compose my drop-down, on each option I put the User ID, and then via jQuery on “on select” I make a location.href towards the URL created with your function:
user_switching::maybe_switch_url( $MyWPuser )
In fact the URL is identical:
wp-login.php?action=switch_to_user&user_id=1234&nr=1&_wpnonce=d6d1234aa1
… but I get a blank page and the error “Could not switch users” … There’s something I’m missing ??
- This reply was modified 7 months, 3 weeks ago by sergio79.
Forum: Plugins
In reply to: [User Switching] Use for woocommerce user switching and order entryOf course I followed the FAQ, and I also inserted:
add_filter( 'user_has_cap', function( $allcaps, $caps, $args, $user ) {
if ( 'switch_to_user' === $args[0] ) {
if (in_array('agent', $user->roles)){
$allcaps['switch_users'] = true;
}
}
return $allcaps;
}, 9, 4 );But when I switch with the generated URL, I get “Could not switch users”…
From the backend, with the administrator level however this does not happen and it works smoothly.
Thanks.
Forum: Plugins
In reply to: [User Switching] Use for woocommerce user switching and order entryIn my case there are Commercial Agents, who should send orders on behalf of customers, using the frontend.
I therefore have my “agent” role defined like this:function add_agenti_role() {
add_role(
'agent',
'Commercial Agent',
array(
'read' => true,
'list_users' => true
)
);
$role = get_role('agent');
$role->add_cap('switch_users');
}
add_action('init', 'add_agenti_role');I tried to get the URL for the user switch like this:
if ( method_exists( 'user_switching', 'maybe_switch_url' ) ) {
$wpUser = get_user_by( 'id', $selectedUserID);
$url = user_switching::maybe_switch_url( $wpUser );
}But the generated URL sends me back to the login page to enter the credentials again, so I also logged out… what am I doing wrong?
PS: the use I would like to make of it is for “internal” use, the frontend functionality will therefore only appear for that small group of users, do you think that the security problems you were talking about could also occur in this way?
Thanks so much <3
- This reply was modified 7 months, 3 weeks ago by sergio79.
I understand, thanks Mikko.
I did a test by calling up my custom template like this:add_filter( ‘relevanssi_live_search_results_template’, function ( $location ) {
return plugin_dir_path(FILE) . ‘/live-ajax-search/search-results-query.php’;
});but I get this error ??
PHP Fatal error: Uncaught Error: Call to a member function have_posts() on null in /…/live-ajax-search/search-results-query.php:25
Forum: Plugins
In reply to: [Relevanssi - A Better Search] post__in filter for cptOk perfect, so I better get the language from $post->ID (of relevanssi_content_to_index) and then make my query to have the content only in that language, fantastic approach!
Forum: Plugins
In reply to: [Relevanssi - A Better Search] post__in filter for cptHi Mikko, fantastic, it’s the function I needed, it works great!
I still have some doubts:
1) Can I make a single select on my external DB by concatenating the 3 fields I need (short description, description, keyword), filtering by $post->ID and putting everything in $content?
2) I use WPML on my site, should I differentiate the contents taken from the external DB based on the language?Thanks as usual!
Forum: Plugins
In reply to: [Relevanssi - A Better Search] post__in filter for cptThanks Mikko, your support is always special.
With relevanssi_content_to_index I will then make a SELECT query on all the fields of my DB/Table external to WP, and these data/fields will be automatically inserted into the index so that relevanssi can do searches on it? Is the association of this external data done automatically based on the post-ID?Forum: Plugins
In reply to: [Relevanssi - A Better Search] Strange problem with WP Grid BuilderIn fact it depended on the number of minimum characters, I had set it to 3 … and my search was “3.00”, thinking they were 4, but with the substitution of the comma character, evidently they are considered 3. I lowered it to 2, and now works. Strange though that “Relevanssi Live Ajax Search” ignored the minimum number of characters I had set in Relevanssi…
Forum: Plugins
In reply to: [Relevanssi - A Better Search] Strange problem with WP Grid BuilderThis is the response from their technical support… it is still not clear how with “Relevanssi Live Ajax Search” everything works normally, and with WP Grid it doesn’t…
“This behavior depends on Relevanssi settings, such as the minimum word length and decimal separators.
When you set Relevanssi as the search engine in the facet settings, it is Relevanssi that queries posts, and the search strings depend on Relevanssi settings.”