Friday, July 29, 2022
HomeWordPress Developmentplugins - Assist understanding dynamic endpoints primarily based on the place a...

plugins – Assist understanding dynamic endpoints primarily based on the place a shortcode is used


I’m new to PHP and WordPress improvement. I’ve plenty of coding expertise with javascript and python so I’ve considerably of an understanding of some issues since PHP is comparable in plenty of methods.

There’s a easy plugin I need to create, largely for studying functions, however I’ve not been in a position to learn how to do it in my search (in all probability as a result of I’m not positive what to name the features I’m making an attempt to execute)

operate roleplay_user_profile() { 
  
    // Shortcode Outcome
    $message="This can be a person profile for ".get_user_meta( $GET_USER_ID, 'nickname', true ); 
    return $message;

    }
// register shortcode
add_shortcode('roleplay_user_profile', 'roleplay_user_profile');

The concept is to place the shortcode [roleplay_user_profile] in a web page known as ‘person’, the place as an alternative of $message I can simply construct the template of how I need to profile to look.

so the web page URL could be ‘samplesite.com/person‘. However I need to get the $GET_USER_ID variable from the url that might seem like this ‘samplesite.com/person/1‘, which for instance, would return $GET_USER_ID = 1.

I might need this to be dynamic, and work even when I have been to vary the permalink of the ‘person’ web page to ‘members’.

I attempted utilizing add_rewrite_endpoint() and add_rewrite_rule(), and dug a bit into different present plugins to see how they use it, however am having a tough time figuring it out. What could be the suitable approach to go about this?

any assist and even hyperlink to a information that I have not been capable of finding could be appreciated!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments