Sabuj Kundu 17th Nov 2021

Problem we faced

At codeboxr while integrating Ultimate Member plugin with our beloved CBX Bookmark & Favorite for WordPress plugin, we were trying to find the default login form id. But the core code of ultimate member plugin seems outdate as seen for the shortcode callback method “ultimatemember_login” in class “Shortcodes”. So as per the current way ultimate member plugin stores information for default login form we tried our way.

Solution for Problem

<code class="language-php">
global $wpdb;

$default_login = $wpdb->get_var(
	"SELECT pm.post_id 
				FROM {$wpdb->postmeta} pm 
				LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_core' )
				WHERE pm.meta_key = '_um_mode' AND 
					  pm.meta_value = 'login' AND 
					  pm2.meta_value = 'login' "
);

//$default_login this is the default login form id that ultimate member plugin create automatically.
</code>

If you want to display the login form then below code will help.

<code class="language-php">
$args = array();
$args['form_id'] = $default_login;
$shortcode_attrs = '';
foreach ( $args as $key => $value ) {
	$shortcode_attrs .= " {$key}=\"{$value}\"";
}

echo do_shortcode( "[ultimatemember {$shortcode_attrs} /]");
</code>

Interested to use our bookmark plugin?

CBX Bookmark & Favorite for WordPress