Support Forum » User Profile

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Saving settings page data to custom table? #15335
    GarySmithGarySmith
    Participant

    I'm not sure any other way to do it really. If the Affiliate Link information was isolated to its own option as a serialized array, perhaps that wouldn't be so bad, the purpose of this is to display the link dynamically. But bundling it with all other settings / options I think would complicate performing the lookup for the link structure we need when getting the ID.

    A user will fill out a field (to replace $userid) and all his children users will see his ID in this link so essentially his affiliate link shows for all people signing up under him. So it might be https://affiliateprogram.com/?id=garysmith.

    Using the serialized option for saving these link formats we could treat each array entry as an ID and render that via shortcode. [aff_link id="1"]. This just lets us know to show the link https://affiliateprogram.com/?id=$userid. But we want to dynamically replace $userid with the current user's parents information so he could get credit for sign-ups or fallback to use the default value which would be saved in the array for each link option (Name of Link, Link, Default).

    To do this we need to save the Option Array ID in the User Meta with whatever value should replace $userid. This could also be serialized where the data is $optionlinkid, $userid in the user_meta I suppose and for however many custom links there are, this could be saved in that format.

    To render this out dynamically for current user we use the ID of the shortcode to correspond to the entry in the options array. That lets us get the link format. Then we check the current user's ID to find in his user_meta his parent user's ID. Then we check the parent user ID user_meta for the serialized value where the option ID and the Name for replacing $userid value coems from. Finally we can render the link with the parent user's saved information to the current user.

    Reading that all back sounds like its as efficient (or inefficient) as if we saved into a custom DB, but the look-up of the option Id might be faster since WP options are cached. It really only works if this option is separate for all other settings options.


    That being said, I can create a field in MetaBoxes to be readonly, can I populate that field with information from the DB. If I wanted to create a numbered ID field for example since I noticed on cloning / repeated elements there is no ID visible. In this example here, each of the options in the array needs an ID for us to confer to the user how to call it in shortcode so I would want to render an ID based on the entries this array has in it.

    in reply to: Code ignored in favor of Builder? #15331
    GarySmithGarySmith
    Participant

    Ultimately I would use code, but its much quicker to use the builder to piece together all the elements of metabox combinations, I had no intention of using the 2 simultaneously. I was just curious of how it worked / what I found. Its good to know now.

    in reply to: Conditional Logic based on Settings Page value #15330
    GarySmithGarySmith
    Participant

    I appreciate the info. I've found the hiding operation to be quite slow, I can clearly see the fields when the page first loads even the ones that work well. I can only make comparison against ACF Pro which I have experience with and looking to see about transitioning from. It has the same limitations mentioned here but its conditional hiding mechanism seems much cleaner at least in this regard.

    in reply to: Saving settings page data to custom table? #15329
    GarySmithGarySmith
    Participant

    I'm re-building a premium plugin I built years and years ago as a premium theme (so old it was built on roots, long before there was ever a Sage theme). I have custom tables for global options. I use the term "settings page" as merely a place in the back-end to allow the user to define whatever options (I know WordPress wants to do away with settings pages in favor of the customizer but I think thats short-sighted and will never be adopted by most developers who want a back-end interface to manage options.). In this case its for creating unique URL combinations for affiliate links. (eg: https://$userid.myaffiliateprogram.com/) where the $userid gets replaced by whichever user it is, so its dynamic.

    Now I could just save these as options in serialized array but there is no limit to the amount of these links being created and they need to be queried and this is just one example. I have another custom table that creates user relationships (affiliate tiers). This could be saved as user_meta but that isn't query friendly when we want multiple levels. (User 5 is Parent to User 3 who is Parent to User 10 etc... ) But from what you're referring to Settings page also wouldn't support saving to user_meta so thats a moot point.

    I want to use ACF Pro or MetaBoxes frameworks but I'd love to do so completely. If I have to go about and create a proprietary back-end page to associate all the custom stuff I need there doesn't seem much benefit in re-building anyway.

    There may be more intelligent ways to accomplish what I want but obviously I'm not aware of them, I can only develop with the skills I have and I don't think the options table and serialized arrays is a good place to build items that need to be queried somewhat extensively, though I could be wrong.

Viewing 4 posts - 1 through 4 (of 4 total)