Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Meta Shortcodes #78

Open
MissVeronica opened this issue Jan 11, 2024 · 2 comments
Open

User Meta Shortcodes #78

MissVeronica opened this issue Jan 11, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@MissVeronica
Copy link
Contributor

Describe the bug
User Meta Shortcodes user_id parameter is not set by um_profile_id() when user_id is empty in the shortcode.

UM Support Forum issue
https://wordpress.org/support/topic/unable-to-get-user-info/

Versions
Tested both version 1.0.0 included in UM Extended 2.0.4
and version 1.0.1 in the old ZIP file format.

@champsupertramp champsupertramp self-assigned this Jan 12, 2024
@champsupertramp champsupertramp added the enhancement New feature or request label Jan 12, 2024
@MissVeronica
Copy link
Contributor Author

MissVeronica commented May 20, 2024

This statement in source code is WRONG

Usage [um_user user_id="" meta_key="" ] // leave user_id empty if you want to retrive the current user's meta value.

Correct statement is

Usage [um_user meta_key="any_meta_key" ] //remove user_id if you want to retrieve the current user's meta value.

Make this clear in the documentation too.
Users are using [um_user user_id="" meta_key="birth_date"] which will not give desired results.

UM Support Forum issue
https://wordpress.org/support/topic/display-custom-field-8/

@MissVeronica
Copy link
Contributor Author

Addition of 'um_user' in the parameter list will allow for usage of the WP filter hook "shortcode_atts_{$shortcode}"

	public function shortcode( $atts ) {

		$atts = shortcode_atts(
			array(
				'user_id'  => um_profile_id(),
				'meta_key' => '', //phpcs:ignore
			),
			$atts,
			'um_user'
		);
		/**
		 * Filters shortcode attributes.
		 *
		 * If the third parameter of the shortcode_atts() function is present then this filter is available.
		 * The third parameter, $shortcode, is the name of the shortcode.
		 *
		 * @since 3.6.0
		 * @since 4.4.0 Added the `$shortcode` parameter.
		 *
		 * @param array  $out       The output array of shortcode attributes.
		 * @param array  $pairs     The supported attributes and their defaults.
		 * @param array  $atts      The user defined shortcode attributes.
		 * @param string $shortcode The shortcode name.
		 */
		$out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants