MyBB Community Forums

Full Version: Custom postbit background (no plugin)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

In this tutorial I will show you how to create a custom postbit background without using a plugin.
Please follow all steps carefully otherwise you will make a mistake, causing it not to work.

Preview:
[Image: aAQHcRT.png]

Step 1:
Login to your ACP and head over to Configuration -> Custom profile fields

Step 2:
Press "add new profile field and add a title and description you wish. Make sure the field type is textbox. 

Step 3:
Add this code into regular expression:
(https:)\/\/i\.imgur\.com\/\w+\.(png|jpe?g|gif)
Thanks to Omar Wink

Step 4:
Maximum length should be 31, all imgur links are 31 characters long. Put the display order to 1.

Step 5:
Turn off required, show on registration and display on profile. However, make sure to turn it on for postbits. Select viewable by all groups, editable by whom ever you want to be able to set a postbit background.

Step 6:
Head over towards your templates and find your postbit template. 

Step 7:
This step is dependable on your theme so you might need to tailor it a small bit. Personally I created a new div but in some cases you could use it on the div's that are there. If you found out where you're going to want the background, add the following code to your div element:
style="background-image:url({$post['fieldvalue']}); height:200px;padding:10px;background-position:center;"

Step 8:
Try it out, see if it works or if it doesn't. 


If you are encountering issues, make sure to use inspect element to determine where your issues are. I recommend to carefully look at step 7 as it has the most possibilities to create an issue.




If you need help or assistance, you can tweet me at @Perileos 
My help/assistance is free as long as you can respect me and my time. 

Kind regards,
A. Longbeach
Thank you for your contribution Smile
(2020-05-16, 09:17 PM)Omar G. Wrote: [ -> ]Thank you for your contribution Smile

Least I can do after you helped me.  Cool
Is there any option to create some url like "usercp.php?action=postbit_cover" in User Control Panel hook?
(2020-06-08, 07:01 AM)Kiddo Monster Wrote: [ -> ]Is there any option to create some url like "usercp.php?action=postbit_cover" in User Control Panel hook?
No, it uses a custom profil field, which is accessible in usercp.php?action=profile
(2020-06-08, 07:33 AM)Crazycat Wrote: [ -> ]
(2020-06-08, 07:01 AM)Kiddo Monster Wrote: [ -> ]Is there any option to create some url like "usercp.php?action=postbit_cover" in User Control Panel hook?
No, it uses a custom profil field, which is accessible in usercp.php?action=profile

Wouldn't it possible to use this:
https://docs.mybb.com/1.8/development/pl...-new-page/

But with usercp.php?
It is possible, but create a new usercp page for a field which already exists in another existing page ? waste of time imho.
It's easyer to add an explanation text.

And doing this needs a plugin... In a tutorial without plugin... insane, don't you think ?
is your tutorial missing something? in your tutorial it says to use $post['fieldvalue']

but tutorial from https://community.mybb.com/thread-226672.html

says to find the fid of the custom profile field and use that number in the template

like $post['fid4'] if the custom profile field is 4
(2020-06-10, 12:38 AM)8guawong Wrote: [ -> ]is your tutorial missing something? in your tutorial it says to use $post['fieldvalue']

but tutorial from https://community.mybb.com/thread-226672.html

says to find the fid of the custom profile field and use that number in the template

like $post['fid4'] if the custom profile field is 4

You could use that as well. 
It's elaborated how to use/determine which field you're picking in the post:
https://community.mybb.com/thread-226672...pid1344223
I think there is indeed something missing, it seems to me it will only work if your custom field is the last by Display Order.
Pages: 1 2