Hiding Content In a Post Based On Dynamically Populated User Meta Key

Question

I use ‘"Dynamic Content for Elementor" Plugin to show or hide stuff on my posts and post templates. usually it works really fine without coding stuff; but the thing I’m trying to do right now is a bit more complex.

i use gravity forms for webinar registrations and after a payment is successful, i add a meta key to the user meta (for example, "webinar_002") and fill it with the webinar’s name; so it’s not empty.
I also used jetengine to create a post type called "Learning Courses" and added a meta key to it, which i use to address the meta key name i used in the gravity forms registration.

And now the problem begins:
I have a section on a post template which i need to be visible only to people whom are registered. so i need to check the user meta value; but i don’t know how to dynamically generate the user meta name.

here is the code i tried to use (but it always returns false):

    $courseid = get_post_meta ( get_the_id(), course_id, true );
$value = get_user_meta ( get_current_user_id(), $courseid, true );
if ( empty( $value ) )
{
    return false;
}

I’m not developer… so… any help would be really appreciated.

0
Artin Sheibani 2 months 0 Answers 11 views 0

Leave an answer