Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Kamuran Bildircin

I need _wpnonce in a link

Hi. I’m including some links in the user list, for example to call up the multisite usersite (frontend), or the WP Ultimo customer view. Everything works wonderfully – partly with ACF. Now, however, I need the _wpnonce for a link. How could I attach it? Would it be possible to use a (own generated) shortcode?

Actually I am using: Custom field: user_id

Before:
<a class=”action” href=”https://mynetwork.com/wp-login.php?action=switch_to_user&user_id=

After:
&nr=1&_wpnonce=????????” target=”_blank”>Login

Thankls and regards,
Steffen

2 years, 10 months ago
Kamuran Bildircin

Hi Stefan,

Thank you very much, but to be honest I don’t really understand this.
Is there somehow maybe a really simple example where in a user list a column XYZ is filled with any text?

>> I’m always surprised about the creative ways our customers use the before and after settings :)
I can give you more of them ;-)

Thank You!
Steffen

2 years, 10 months ago
Stefan van den Dungen Gronovius
Developer

Something like this should work (not tested):

add_filter( 'ac/column/value', function( $value, $id, AC\Column $column ){
	if( $value && $column instanceof AC\Column\CustomField && 'user_id' === $column->get_meta_key() ){
		$nonce = 'nonce'; // populate with nonce
		$value = sprintf( '<a class="action" href="https://mynetwork.com/wp-login.php?action=switch_to_user&user_id=%s&nr=1&_wpnonce=%s" target="_blank">Login</a>', $value, $nonce );
	}

	return $value;
}, 10, 3 );
2 years, 10 months ago
Kamuran Bildircin

Hello Stefan,

Thank you. But I am too stupid.

My very simple code for testing:
problem-3

My column:
problem-2

What am I doing wrong?

Thank You!
Steffen

2 years, 9 months ago

You must be logged in to reply to this topic.