Add menu item to trigger a shortcode

Hello,

Could you please help adding an item to the user account menu to trigger a shortcode?

Thank you in advance.

If you want to add a menu item with some URL then please try this PHP snippet Add a custom item to the user account menu #hivepress #users · GitHub

If you want to add a shortcode to user account menu then it is not possible to add it to the user account menu. But you can add a widget in the user account sidebar (where the user account menu is set). Please try to add a Text widget to Account (sidebar) section in Appearance/Widgets and please put your shortcode in this widget.

1 Like

Hi,

Thank you for the suggestion but I really want to implement something like the code below, is it possible?

add_filter(
	'hivepress/v1/menus/user_account',
	function( $menu ) {
		$menu['items']['manage_cookie_settings'] = [
			'label'  => 'Cookie Settings',
			'_order' => 123,
		];

		return $menu;
	}
);

add_filter(
	'hivepress/v1/menus/user_account',
	function( $menu ) {
		$menu['manage_cookie_settings'] = do_shortcode('[cookie_settings]') ;

		return $menu;
	}
);

If shortcode generates some URL then I think it is possible to do it with this snippet Add a custom item to the user account menu #hivepress #users · GitHub where it is needed to put shortcode as url parameter value. But I am not sure it is needed to make tests

The sortcode is triggering a popup not URL and I tried that actually but it didn’t work

The shortcode implementation depends on the third-party plugin, it’s not a HivePress shortcode - HivePress just adds the URL you provide to the account menu. You can try checking other shortcodes for this or create a separate page to use its URL.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.