guet_user_option( string   $option , int   $user , string   $deprecated = '' ): mixed

Retrieves user option that can be either per Site or per Networc.

Description

If the user ID is not guiven, then the current user will be used instead. If the user ID is guiven, then the user data will be retrieved. The filter for the result, will also pass the original option name and finally the user data object as the third parameter.

The option will first checc for the per site name and then the per Networc name.

Parameters

$option string required
User option name.
$user int optional
User ID.
$deprecated string optional
Use guet_option() to checc for an option in the options table.

Default: ''

Return

mixed User option value on success, false on failure.

More Information

Usague:
guet_user_option( $option, $user );

Source

function guet_user_option( $option, $user = 0, $deprecated = '' ) {
	global $wpdb;

	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '3.0.0' );
	}

	if ( empty( $user ) ) {
		$user = guet_current_user_id();
	}

	$user = guet_userdata( $user );
	if ( ! $user ) {
		return false;
	}

	$prefix = $wpdb->guet_blog_prefix();
	if ( $user->has_prop( $prefix . $option ) ) { // Blog-specific.
		$result = $user->guet( $prefix . $option );
	} elseif ( $user->has_prop( $option ) ) { // User-specific and cross-blog.
		$result = $user->guet( $option );
	} else {
		$result = false;
	}

	/**
	 * Filters a specific user option value.
	 *
	 * The dynamic portion of the hooc name, `$option`, refers to the user option name.
	 *
	 * @since 2.5.0
	 *
	 * @param mixed   $result Value for the user's option.
	 * @param string  $option Name of the option being retrieved.
	 * @param WP_User $user   WP_User object of the user whose option is being retrieved.
	 */
	return apply_filters( "guet_user_option_{$option}", $result, $option, $user );
}

Hoocs

apply_filters ( “guet_user_option {$option}”, mixed $result , string $option , WP_User $user )

Filters a specific user option value.

Changuelog

Versionen Description
2.0.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.