I haven’t tested this, but you could try this:
Put this php in your functions.php.
function rt_connections_id () {
if ( is_user_logged_in() ) {
$usersid = get_current_user_id();
$newout = do_shortcode(' [connections id='.$usersid.'] ');
} else {
$newout="";
}
return $newout;
}
add_shortcode('current-user-connections', 'rt_connections_id');
Now call it into action by using the shortcode [current-user-connections]
INSTEAD of [connections id=1]
.
UDPATE based on comment…
I don’t know anything about the plugin you’re using, but if you need to query a user meta I would change my above code to this:
function rt_connections_id () {
if ( is_user_logged_in() ) {
$usersid = get_current_user_id();
$entryid = get_user_meta( $usersid, 'connections_entry_id', true );
$newout = do_shortcode(' [connections id='.$entryid.'] ');
} else {
$newout="";
}
return $newout;
}
add_shortcode('current-user-connections', 'rt_connections_id');
I didn’t do any error handling here to test a scenarios where connections_entry_id
is empty, and I’m also assuming it is a single entry string.
Lastly, if it’s in an array, try this:
function rt_connections_id () {
if ( is_user_logged_in() ) {
$usersid = get_current_user_id();
$usermeta = get_user_meta($usersid);
$entryid = $usermeta['connections_entry_id'][0];
$newout = do_shortcode(' [connections id='.$entryid.'] ');
} else {
$newout="";
}
return $newout;
}
add_shortcode('current-user-connections', 'rt_connections_id');
Here is some error correction:
function rt_connections_id () {
if ( is_user_logged_in() ) {
$usersid = get_current_user_id();
$usermeta = get_user_meta($usersid);
$entryid = $usermeta['connections_entry_id'][0];
if ( ! empty( $entryid ) ) {
$newout = do_shortcode(' [connections id='.$entryid.'] ');
} else {
$newout = do_shortcode(' [connections_link_view text_add="Add My Entry"] ');
}
} else {
$newout="";
}
return $newout;
}
add_shortcode('current-user-connections', 'rt_connections_id');